If you are like me, then you enjoy deploying stuff in the cloud.   There is just something great about setting up DNS, SSL, changing server config files, and debugging things when things don’t behave as expected.  The fun part is that you may find a tutorial on how to setup WordPress, but then, the tutorial is for people who are setting it up on a Digital Ocean server, not whatever you’re using.  Or maybe you have a plugin you are installing, and then that doesn’t work, and the way to fix it is specific to wherever you are deploying it.  So with that in mind, I’m creating a post to detail how I setup WordPress on Google Cloud Platform (GCP), with SSL (for free), SEO, a premium theme (I’m using Avada), and some of the other things you might want along the way.

 

1. Register a Domain

For the sake of simplicity, I’m using all Google stuff for this tutorial. But it’s really easy to just register a domain name at Google Domains. I don’t think this part is very complicated, just click on buttons that look relevant.

2. Create a new Google Cloud Project

If you haven’t signed up for Google Cloud, you can do that easily enough here, and you get $300 to get going. Just don’t spend it all in one place. Pro-tip: In the past I have accidentally gone through their tutorials for setting up load balancers, or whatever, and forgot to delete them, and was charged. So just be sure to be careful with removing resources you aren’t using. Once inside the console, create a new project at the top of the screen, and name it whatever you want, the name doesn’ t matter (e.g. my-blog). If you have any difficulty doing this, have a look at this Google tutorial.

3. Launch a Pre-packaged WordPress Installation with one Click

Google Cloud Platform has some prepackaged deployments that you can use to deploy WordPress. At this link you can get your WordPress blog up and running with one single click. Just choose the size of the VM you would like to use, along the way, you will see a screen where you need to choose whether to allow https, go ahead and select that, since later we’ll be adding https, and boom, you have a wordpress site up and running. Of course you’ll still need to follow the rest of these steps before you crack open a beer, however.

4. Point your Domain to your server IP

Now you will have a WordPress installation running somewhere on the internet.  Once Google has completed the installation, you should see the IP address of your server listed on the summary of the installation.  You can type that into your browser and see that it is running.  Now then, head back over to your Google Domains link, and create an A Record to point the Domain to your server.  Go to “My Domains”, find your domain, and then click on the “DNS” tab.  Then near the bottom you will see a place to add an A Record under the section “Custom Resource Records”.  A Record should already be selected, so just type in your IP address of the server, and you should be done.  It may take a while to update, but when it does you should be able to now go to whatever your domain name is and see your new site.

5. Setup SSL

It’s easier to setup SSL at this point, since if we wait to add SSL until after we have uploaded a bunch of pictures, installed a theme, etc, we would then have to update the links to use https, etc.  So let’s do it now.  Just make sure you have waited long enough for your DNS settings to have taken affect. If you don’t know what SSL is, that’s the lock you see next to the url in your browser when you visit secure sites.  You really want to have that on your site, otherwise people can snoop on visitors to your site, etc.  Contrary to what some may believe, SSL is free, thanks to the folks at Let’s Encrypt.  What they have created is a script called certbot that will automatically renew your SSL certificates for free every three months.  If you set it up right, you won’t have to worry about it again.  No more paying your web host a trillion dollars to give you certificates that should be free.  And thanks to those good people at Let’s Encrypt, we just need to run a couple of commands on our server, and SSL is setup!  Basically, GCP (Google Cloud Platform) has set our WordPress blog on a Debian variety of Linux.  So you can read for yourself on the Let’s Encrypt site how to get SSL setup on Debian, or you can just SSH into your instance, by finding your compute instance in your Google Cloud Console, and clicking the SSH button, and then doing the following:

sudo apt-get install certbot python-certbot-apache -t stretch-backports

then

sudo certbot --apache

and then when prompted just answer the questions, and presto, you have SSL installed.  You will still need to go into your wordpress site, and update the url settings in the Settings tab of your WordPress Admin sidebar, to use https://mysitename.com rather than the http and ip address.  SSL should now be working, and Let’s Encrypt will auto-renew your certs every three months.  If something isn’t working, you might want to double check you have your compute instance set to allow https traffic.

6. While we’re inside our Compute Instance, a couple of housekeeping things

Let’s take care of a couple of config changes while we are inside the terminal of our server.  One thing we need to do is update an Apache directive to allow us to update our WordPress permalinks, and other things related to rules we may add to our .htaccess file later.  Otherwise, you may add stuff to your .htaccess file, and it will never take effect.  We will update the AllowOverride directive, and if you are super curious you can read about it here, but that is just extra-credit, since I think it is a rather confusing read.  Basically open the config file for editing by running:

sudo vim /etc/apache2/apache2.conf

If you haven’t used many vim commands before you can search for the line you need by simply typing a slash, “/”, followed by AllowOverride, then moving down to the block where you see “Directive /var/www/”

        
    
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
     

Make sure you are editing the part inside the Directive for “/var/www/” because there are a couple of different ones there. Then press “a” to enable edit mode.  delete “None” and replace with “ALL”, then hit escape, and then type “:x” enter to save and quit.  Be careful not to leave any stray marks or even unnecessary whitespaces, since these configuration files can break very easily, and then your website will be down.

Next you can change your php.ini settings, since themes like Avada might want you to increase some of the settings.  Open the correct php.ini file (there are several of them), by doing the following:

sudo vim /etc/php/7.0/apache2/php.ini

then set the values for max_execution_time to 180, and max_input_vars t0 1620, if you see that there is a “;” before the variable that means it’s commented out, so get rid of the semi colon. and save and quit.

Now you will need to restart your apache server for the changes to take effect. So, run:
sudo service apache2 restart

7. Purchase and Install the Avada Theme

You can purchase an Avada license and download the theme at theme forest. This is just the theme I chose. It has good documentation and support. So it seems to do the trick for me. But the process is probably pretty similar no matter which theme you purchase.  Once you purchase and download it, just follow the instructions in this Avada tutorial to upload it to your WordPress site.  You’ll need to follow instructions for creating an Avada key, in order to install and activate the premium plugins that it comes with.  Go to the Avada tab, and follow instructions to add that key.  Then you can read this to install whatever Avada Demo you might have your eye on.

8. Activate the Yoast SEO Plugin

The Seo plugin from the folks at Yoast is really great.  It should already be there when you install Avada, and is free.  Now simply activate it and read whatever suggestions they may have.

9. Setup Contact Forms

If you happen to want to use contact forms, on GCP, you will need to install another plugin and associate the form with a gmail account of yours.   Install the plugin WP Mail SMTP. Here is a tutorial on how to set that up.

10. Fix Permalinks to get rid of that pesky “index.php” in the URL

If you are like me, then you may not care for everyone having to see “index.php” in your url. So now that you have enabled AllowOveride you can go to the WordPress Settings tab and click Permalinks, and change the “custom” url by just deleting the index.php from the string. And It should all work.

Boom, you’re basically done! Hopefully it’s all working now! Good Job, now go for a swim, or get some pizza, you deserve it!