
HTTPS on localhost
The usage of https is the norm now, and so more and more we’ll need to use HTTPS even for local development. So after some mixed results – this guide solved all my problems:
https://web.dev/how-to-use-local-https/
https://github.com/FiloSottile/mkcert#installation
First we install ssl-tools
sudo apt install libnss3-tools
Then install mkcert:
curl -JLO "https://dl.filippo.io/mkcert/latest?for=linux/amd64"
chmod +x mkcert-v*-linux-amd64
sudo cp mkcert-v*-linux-amd64 /usr/local/bin/mkcert
After this – setup mkcert to accept the self signed certificates:
mkcert -install
Then – for each localhost site we do the following:
mkcert example.local
And then – we use the newly created files in the configuration. For this example – apache2:
<VirtualHost *:443>
ServerName my.site
DocumentRoot /path/to/site
#SetEnv APPLICATION_ENV "development"
<Directory /path/to/site/>
Options FollowSymLinks
DirectoryIndex index.php
AllowOverride All
Require all granted
</Directory>
SSLCertificateFile /path/to/cert.file
SSLCertificateKeyFile /path.to.key
ErrorLog ${APACHE_LOG_DIR}/my.site.error.log
CustomLog ${APACHE_LOG_DIR}/my.site.access.log combined
</VirtualHost>