Setting Up Ghost with Google Cloud

Setting Up Ghost with Google Cloud

So, you want to setup a blogging service, but do not want to worry about paying 20 dollars a month to WordPress or Ghost for a subscription fee.  Well, you are in luck, because the Ghost blogging platform can be run on Google's Cloud infrastructure for less a quarter of the cost.  

This blog post will also talk about signing up for a custom domain to utilize as well. A custom domain name is not a requirement, but know that your IP address might change, and you will have to login to the Console every time you want to access your blog. There are many different domain registrar services on the Internet, and most are equally priced.  I simply chose Google domain name services to keep all products on the same platform.  First step is to navigate to Domains on Google.   Choose a domain name and work through the registration process.  You can either choose to register with private information or to have public information.  

Once your domain name is registered you must go into the configuration settings and make sure the domain name is pointing to the appropriate Google name servers.

Once all DNS registration has been completed, we can work towards installing the Ghost platform.  Navigate to the Google Console and sign up for an account.  This portion does require a credit card to be on file for any charges.  However, as of June 2018, Google still has an ongoing deal where new users can receive 300 dollars for 365 days of compute time.  

Click on the Menu button in the top left corner of the Google Cloud Platform page, and navigate to Compute Engine --> VM Instances.  

Choose Create Instance.  

Fill out the information fields appropriately.  I would recommend picking a region somewhat close to you geographically.  This will help with latency when uploading files or performing connections.  Of course, if this device is going to be geographically targeting a different portion of the world it might be best to position it close to your target demographic.  

For resources of the machine, Ghost requires at least 1 GB of memory, thus the small machine type is the smallest to run Ghost.  However, you might be able to lower your resources after installation.  Your mileage might vary.  As well, Ghost requires Ubuntu 16.04 LTS support, and adjust the disk space accordingly (remember you will pay per GB for storage).  Finally, allow HTTP/HTTPs traffic to your VM instance.  

Once created, you should have the following in your current VM instances page.  As you can see your VM will have both an internal and external address.  Currently that external address is a Dynamic address and could change based on Google's networking needs.  This can be changed from Dynamic to  Static by navigating to the menu button in the top left, and then choosing Networking --> Network Services --> Cloud DNS.  

On the Cloud DNS page you will see your currently held External Address.  Under Type you can pull down the arrow and choose the Static selection.  It should be noted that by changing the IP address from Dynamic to Static it will incur an additional fee on a monthly basis, but this is the only way to setup your custom domain purchased earlier.  

Now that our address is static, we can add Record sets by clicking the Add Record Sets at the top of the Cloud DNS page.  This is an example, of what my current record set looks like.  

Return to your VM instance menu by choosing Computer Engine --> Current Instances.  Now choose the SSH button on the far right.  Google should launch a new window that will open an interactive shell to your remote machine.  By choosing SSH from the web browser Google will help with obtaining the session by passing the necessary keys to authenticate.  If you want to use an SSH client such as Putty or the Linux command line you will need to obtain the private key from Google first.  

The installation process for Ghost is very straight forward and can be referenced at the following link: https://docs.ghost.org/docs/install.  I have provided a list of the necessary commands to run in order.  Make sure to follow any on-screen instructions that prompt for user input, and make sure to keep track of any passwords created during the process.  

# Update and install nginx & mysql
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install nginx mysql-server
# make sure to setup a password when install mysql-server this will be
# used later

# install Node and NPM
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash 
sudo apt-get install -y nodejs
sudo npm i -g ghost-cli

# setup folder structure
sudo mkdir -p /var/www/ghost
sudo chown [user]:[user] /var/www/ghost
sudo chmod 775 /var/www/ghost
cd /var/www/ghost

# run the ghost-cli installer
ghost install
# follow the on-screen instructions

The screenshot below shows Ghost performing installation checks.  

Follow along with the on-screen instructions.  During this stage if you have your domain name already setup you can simply enter that here when Ghost asks for your blog URL.  You can also determine if you want to install a SSL/TLS certificate at this stage of the setup.  If you have your domain name setup correctly I would advise letting the installer help with the setup and configuration.  Ghost downloads and utilizes the acme installer straight from the Let's Encrypt site.  This will help walk through an automated configuration of encryption setup for Nginx.

Once all installation is completed you should see the console report starting Ghost.  

Navigating to your IP address or domain name should greet you with a working Ghost Blog.  It should be noted at this stage there are no current user accounts setup, and the first person to sign up for an account will control the blogging platform.  Thus, it is imperative to navigate to /admin or /ghost , and fill out the necessary account creation information.  

Be careful of what email address you use on the account creation as this will be the username you use to login to the administrative section of the blog platform.  It should also be noted that even though Ghost currently asks for your email address email sending functionality will not be enabled.  

Since email functionality is not configure clicking the skip button for Inviting Users is recommended.  

Now you should see the administrative portal for the Ghost Blog as shown by the screenshot below.  

In order to view the Ghost main page simply remove the /ghost directory.  

That completes the configuration and setup of a base Ghost blogging platform on Google Cloud services.  Good luck and have fun blogging!

Ryan Villarreal

About Ryan Villarreal