• We just launched and are currently in beta. Join us as we build and grow the community.

HOW TO CREATE SSL CERTIFICATES AND ENABLE HTTPS ON LOCALHOST SITE

Notagay

Developer Environment Architect
N Rep
0
0
0
Rep
0
N Vouches
0
0
0
Vouches
0
Posts
149
Likes
50
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 400 XP
https://cdn.jsdelivr.net/joypixels/assets/6.6/png/unicode/64/0031-20e3.png[/img For this, go to the corresponding path /etc/ssl :
cd /etc/ssl
Request root permissions :
sudo -i
https://cdn.jsdelivr.net/joypixels/assets/6.6/png/unicode/64/0032-20e3.png[/img Create a certificate :
openssl req -x509 -newkey rsa:2048 -keyout mylocalhost.key -out mylocalhost.pem -days 365 -nodes
It will ask you to enter details, you can either skip, or put random details. It's up to you.
https://cdn.jsdelivr.net/joypixels/assets/6.6/png/unicode/64/0033-20e3.png[/img Copy the files to the folders
cp mylocalhost.key private/
cp mylocalhost.pem certs/
a2enmod ssl
The key file goes to the private folder, while the pem file goes to certs folder.
https://cdn.jsdelivr.net/joypixels/assets/6.6/png/unicode/64/0034-20e3.png[/img Install nano and edit the config file :
sudo nano /etc/apache2/sites-available/default-ssl.conf
Search for "SSL ENGINE SWITCH", you can do that with CTRL+W (twice).
Now we edit :
SSLCertificateFile and SSLCertificateKeyFile
Replace the ssl-cert-snakeoil.pem with mylocalhost.pem and ssl-cert-snakeoil.key to mylocalhost.key.
Should look like this :
SSLCertificateFile /etc/ssl/certs/mylocalhost.pem
SSLCertificateKeyFile /etc/ssl/private/mylocalhost.key
To save, hit ctrl + s.
https://cdn.jsdelivr.net/joypixels/assets/6.6/png/unicode/64/0035-20e3.png[/img Enable the config
a2ensite default-ssl.conf
sudo service apache2 restart
 

428,436

311,073

311,082

Top