Today we’re going to take a look at how to Setup and Install WordPress on Google Cloud - Google Click to Deploy, configure OpenSource SSL, and enable essential services through Debian CLI to keep WordPress Instance streamlined.
Setup WordPress On Google Cloud and Configure LetsEncrypt OpenSSL
Google Cloud Platform, offered by Google, is a suite of cloud computing services that run on the same infrastructure that Google uses for its end-user products, such as Google Search, Google Drive, Android, YouTube. read more
Let's get started
1. Setup an Instance
Get $300 To Try Google Cloud
Use products & Services offered by Google for free up to the specified usage limits during and past the free trial. These usage limits are subject to change and only available for eligible customers. view details
Create New Project In Google Cloud Platform
Once you’ve signed up for Trial or purchased Google Cloud, you’ll need to log into your Google account and access the Google Cloud Console. From the Project drop-down, click Create project:
Deploy WordPress & Configure Instance.
After creating a project, Let's Click on Go to Cloud Launcher and select WordPress Google Click to Deploy on next page.
Click - Launch on Compute Engine
- Enter Deployment Name - Deployment name can only contain lowercase characters, numbers or dashes. It must start with a lowercase letter and cannot end with a dash.
- Select Zone - The zone determines what computing resources are available and where your data is stored and used Learn more
- Configure Machine Type - Machine types determine the specifications of your machines, such as the amount of memory, virtual cores, and persistent disk limits an instance will have. Learn more about machine types
- Enter Administrator Email - This email will be used if you need to reset your password.
- Select Install phpMyAdmin
- Boot Disk Type - Storage space is much less expensive for a standard persistent disk. An SSD persistent disk is better for random IOPS or streaming throughput with low latency. Learn more
- Firewall - By default, all incoming traffic from outside a network is blocked. Select the type of network traffic you want to allow. Learn more Check both Allow HTTPS & HTTPS Traffic.
- Finally, Click on Deploy and Wait for Google to generate IP Address & Credentials for your WordPress Instance.
Step 2. Configure Domain
Update Domain's IP Address for forwarding
Furthermore, Login to your Domain Control Panel, Navigate to DNS Zone and update the IP address for forwarding in 3 simple steps.
- Host Name - Enter the host name the A record links to. Type @ to point the record directly to your domain name, including the www.
- Points to IP Address - Enter 184.108.40.206 (Example)
- TTL - Select how long the server should cache the information.
Note: It should take a few minutes for DNS to propagate. However, you can expect a propagation time up to 24 hours. This is because it takes time for the DNS to take effect across the internet. Make use of DNSChecker to check DNS data collected from all location for confirming that your domain is completely propagated or not worldwide.
Configure Domain in WordPress Dashboard
Once you know that the Domain is propagated. You need to update domain name in WordPress Dashboard. Simply, Go to Settings, Click on General & Replace IP Address with Domain Name.
After Saving Changes, your domain name will be updated and you will be redirected to new WordPress Login page.
Step 3. Install SSL
Configure SSL to Redirect Traffic from HTTP to HTTPS
HTTPS protects the integrity of your website. HTTPS helps prevent intruders from tampering with the communications between your websites and your users' browsers. Intruders include intentionally malicious attackers, and legitimate but intrusive companies, such as ISPs or hotels that inject ads into pages. In the next few steps, I am going to show you how to set up and configure LetsEncrypt, Certbot OpenSSL certificate.
Navigate to Deployment Manager and click on SSH to launch terminal. Also, we'll need to edit some files so here's the list of VIM Editor Commands
Run following commands in Terminal for generating SSL certificates and redirecting site from HTTP to HTTPS.
sudo apt-get install git
Clone Certbot from Git and configure SSL
You can directly install a Certbot package on your Instance from Github by running the following command.
sudo clone git https://github.com/certbot/certbot.git
Go to Certbot directory
Run Certbot-Auto Package
Important Steps of Configuration:
- Agree with terms and conditions
- Enter your Email address to receive expiry notifications within 90 Days
- Enter Domain Name for SSL Configuration.
- Select 2 to redirect HTTP traffic to HTTPS
- Restart Apache
sudo /etc/init.d/apache2 restart
Remember Pages/Posts may return 404 Error after deploying SSL on your WordPress Instance. It's common and in my experience one of the best things that can happen because you get to learn throughout the process as a beginner. Learn how you can fix 404 Error by clicking here.
Configure Certbot to Auto-Renew LetsEncrypt SSL.
Now that we have Setup LetsEncrypt SSL, we need to configure Certbot Auto-Renew script to ensure that our Website always redirects to HTTPS.
Steps of Configuration:
We have deployed Certbot in the home directory, Lets, go back to Terminal and locate Certbot-Auto Package in Certbot folder.
ls cd certbot
If you have downloaded the certbot-auto package to a different directory, it is important to locate it. If you cannot locate the certbot-auto package, you can re-download the package by executing the following command:
wget https://dl.eff.org/certbot-auto && chmod a+x certbot-auto
Now, we need to move a Certbot Auto-package file to LetsEncrypt directory by executing following command :
sudo mv certbot-auto /etc/letsencrypt/
Next, we need to edit Crontab file. You can open your crontab file by executing the following command.
sudo crontab -e
At the bottom of your crontab file, you will enter a script which will tell your server to check for certificate renewals once per week and to automatically renew the certificates if they are about to expire.
Copy Paste the following Command
45 2 * * 6 cd /etc/letsencrypt/ && ./certbot-auto renew && /etc/init.d/apache2 restart
That's it!, thanks for making it to the end 🙂
Now that you've Setup WordPress On Google Cloud & Configured SSL, You don't need to worry about renewing SSL again! You can go ahead Boldly Say "Hello World"
If you are working in the field of Cloud computing or interested to learn, i’ve got a practical read for you about getting certified from Google Cloud in 2019.
I've also got this Data Science newsletter that you might be into. I send a tiny email once or twice every quarter with some useful resource I've found. Don't worry, I hate spam as much as you. Feel free to subscribe. ↗