Last active
February 17, 2023 20:40
-
-
Save obviousdisaster/1e549ab3001ea5a4460f4394de5bbdbf to your computer and use it in GitHub Desktop.
Set up SSL certs for local development. Only method that's worked for me. Tested on Ubuntu v20.x
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# my default apache ssl conf, playground.test is the local site | |
# | |
Define servername playground.test | |
<IfModule mod_ssl.c> | |
<VirtualHost _default_:443> | |
ServerAdmin webmaster@localhost | |
ServerName ${servername} | |
DocumentRoot /var/www/html/${servername} | |
<Directory "/var/www/html/${servername}"> | |
Order allow,deny | |
Allow from all | |
AllowOverride all | |
Require all granted | |
</Directory> | |
ErrorLog ${APACHE_LOG_DIR}/${servername}-ssl-error.log | |
CustomLog ${APACHE_LOG_DIR}/${servername}-ssl-access.log combined | |
SSLEngine on | |
SSLCertificateFile /home/markhall/ssl-certs/${servername}.pem | |
SSLCertificateKeyFile /home/markhall/ssl-certs/${servername}-key.pem | |
<FilesMatch "\.(cgi|shtml|phtml|php)$"> | |
SSLOptions +StdEnvVars | |
</FilesMatch> | |
<Directory /usr/lib/cgi-bin> | |
SSLOptions +StdEnvVars | |
</Directory> | |
</VirtualHost> | |
</IfModule> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# my default apache non-ssl conf, playground.test is the local site | |
# | |
Define servername playground.test | |
<VirtualHost *:80> | |
ServerAdmin webmaster@localhost | |
ServerName ${servername} | |
DocumentRoot /var/www/html/${servername} | |
ErrorLog ${APACHE_LOG_DIR}/${servername}-error.log | |
CustomLog ${APACHE_LOG_DIR}/${servername}-access.log combined | |
<Directory /var/www/html/${servername}> | |
DirectoryIndex index.php index.html | |
</Directory> | |
</VirtualHost> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# store all ssl's in home | |
mkdir $HOME/ssl-certs | |
cd ~/ssl-certs | |
mkcert -install | |
# playground.test is our test site | |
mkcert playground.test | |
# apache conf files | |
cd /etc/apache2/sites-available/ | |
# create playground.test.conf | |
# create playground.test.ssl.conf | |
# edit hosts file with new local site | |
sudo /etc/hosts | |
# add line | |
127.0.0.1 playground.test | |
# enable the site in apache | |
sudo a2ensite playground.test.* | |
# reboot apache | |
sudo systemctl reload apache2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated mkcert as it's part of PopOS install, no need from brew install.