Steps to install free SSL certificates using Lets Encrypt on Google Cloud based Wordpress installation.
All the paths below are based on assumption that you’ve used one-click-install Google Launcher version of Wordpress. Also, in the steps below replace ‘balajiextrusions’ with your own site name
Installation
Login to your Compute instance using SSH
Change to super user
Install git if absent
If for above, it says command not found then run the following
Clone the letsencrypt github repo
Run the SSL certificate command
The above command will guide you through the steps (will ask for email and other details).
If it asks to select the .conf file, select default-ssl.conf
Error in selecting ssl conf file
In my case, after selection it gave error similar to server name not found
. I reselected the same default-ssl.conf
file couple of times and that error went away.
It expects ServerName to be present in default-ssl.conf. I am not sure whats the purpose of this field. Anyways, I was able to work through the problem without adding ServerName.
Error in installation
After the installation you might see this error
I faced this error too. Don’t worry, lets remedy that using a manual step.
Open default-ssl.conf file
Add the lines from DocumentRoot
until </Directory>
at appropriate position
Redirect all http links to https
Open default-ssl.conf file
Add new VirtualHost tag as below, after existing VirtualHost tag and before </IfModule>
Wordpress configuration
Ensure all Wordpress permalinks follow https by changing URL in Wordpress Admin -> Settings -> General
Note: Once URL is updated and apache is restarted, your wordpress admin URL will change from IP based (xxx.xx.xx.xx/wp-admin) to domain based (balajiextrusions.com/wp-admin)
Restart apache
Restart apache service for changes to take effect
Certificate auto-renewal
LetsEncrypt certificate expire every 90 days. So schedule cronjob to auto-renew it say every month.
Open crontab
Add this line to the file (update your letsencrypt directory path as applicable)
This new command is saved to a temp file (it will ask you for location), and then add it to actual cron
Confirm and rejoice
That’s it. You are done. Enjoy free https.
Feel free to comment if you need any help with above steps.
Update (July 2016): The steps listed below still work but are outdated. LetsEncrypt now recommends Certbot which is super easy to install and use. It auto creates the certificates and also deals with renewals.
Tags: google-cloud wordpress https letsencrypt