Overview
Learn how to install Ghost CMS on AWS step by step.
Blogging has become a booming career choice for many people. And WordPress has obtained much popularity in blogging field. Even though many are still searching for some other platform which can overcome the problems in WordPress.
There comes Ghost, A node and JavaScript-based content management system built for blogging enthusiasts.
But why Ghost, if we have already a well-established platform like WordPress?
Here is the reason, According to Google’s penguin ranking algorithm, loading speed is one the key factor to a blog’s success. And ghost did it fantastically. A ghost based blog will load much faster than a typical WordPress blog.
Ghost uses a minimal approach to set up a blog. Unlike WordPress, Ghost can be used only for blogging. And ghost blogs can be integrated with all of your favourite technologies and have the capabilities to boost your SEO with inbuilt SEO tools.
As of now, Ghost can only be installed on a dedicated server. However, team ghost provides a premium plan to host the blog on their server. But they are ridiculously costly.
But we have an alternative option to try ghost absolutely free for a year using amazon web services. Here in this article, I’ll guide you to install ghost on an AWS EC2 instance.
AWS is a cloud computing platform which provides dedicated servers and they are very fast compared to other hosting platforms. For the purpose of this guide, I’m going to use a free tier of amazon web services. So, let’s dive into it.
Create a new EC2 instance
Login to your AWS account and create a new EC2 instance.
Follow the series of steps to ensure you are launching the instance properly. Choose the ubuntu 18.04 server as the amazon machine image(AMI).
In the next step, you are asked to chose an instance type. Here we’ll use general-purpose t2.micro instance type which is included in our free tier.
Coming next we need to generate a secure key file (.pem) which we’ll use later to connect the instance using SSH. Make sure you save this key file in a secure location as we can’t download it again.
Configure storage space
Next, we can configure the storage space for the instance. Here I’m not going to extend the space but make sure you expand the space to get rid of space issues later. (up to 30GB in free tier)
After configuring the storage space we’ll need to configure the security group to access the instance from outside. Here, port 22 used by SSH will be open by default. And we’ll open an additional port 80 to allow the incoming HTTP connections. Later you can open more ports like HTTPS if you are interested to secure the blog with an SSL certificate.
Now click on the Review and Launch button and the instance will be running in a few minutes.
Installing Ghost CMS on the AWS instance
Earlier while setting up instance we saved a key file from AWS. We’ll be using that file(.pem) to connect to the EC2 instance using SSH. Open a console and navigate to the key file directory and connect to the instance as follows,
cd Downloads && sudo chmod 400 ghostblog.pem #making it as an executable file
#find the same command from connect option in EC2 instance section.
ssh -i "ghostblog.pem" ubuntu@ec2-13-233-60-197.ap-south-1.compute.amazonaws.com
After when the connection established, we can continue with the installation.
# Update package lists
sudo apt-get update
# Update installed packages
sudo apt-get upgrade
Install Nginx server.
sudo apt-get install nginx
Now we need to allow the Nginx server in the firewall.
sudo ufw allow 'Nginx Full'
Ghost uses MySQL database as the production database. We can install and configure it by running below commands.
# install mysql
sudo apt-get install mysql-server
# Set a password
sudo mysql
# Replace 'password' with your password, but keep the quote marks!
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
# Then exit MySQL
quit
# and login to your Ubuntu user again
su - <user>
Ghost uses NodeJS and Express framework as a web server.
# Add the NodeSource APT repository for Node 10
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash
# Install Node.js
sudo apt-get install -y nodejs
Until now, we have successfully installed and configured all the dependencies for the ghost. We are ready to install ghost on our system.
sudo npm install ghost-cli@latest
Ghost provides the ghost-cli to manage the ghost instance. Here we are using the same ghost-cli to install the ghost blog.
# We'll create a directory called blog to install ghost
sudo mkdir -p /var/www/blog
# Replace <user> with the name of your user who will own this directory
sudo chown <user>:<user> /var/www/blog
# Set the correct permissions
sudo chmod 775 /var/www/blog
# Then navigate into it
cd /var/www/blog
After creating and setting up proper directory permissions we can install ghost by running the below command.
ghost install
This command will ask you a series of questions regarding ghost setup. We’ll be using the EC2 public address to install our blog.
Enter blog url: Ec2 Ip address eg: 13.233.50.195 # you can obtain this from connect section of AWS EC2 instance.
Mysql host name: localhost
mysql username : root
mysql password: #one you setup earlier
Do you want setup mysql user: Yes
Setup Nginx: Yes
Setup SSL: No for now
Setup Systemd: Yes # we'll use systemd to start and stop ghost
Start ghost: yes
Finally, we are successfully installed ghost cms on our AWS EC2 instance. Open up a browser and access the URL which ghost installation provided in the console.
http://13.233.50.195/ghost/
As of now, we are using the EC2 IP address to install the blog. We can also point our domain to ghost instance using AWS Route53. If you are interested to install SSL and use third party domain, make sure you read this article.
Read here, Installing Ghost CMS: Setting up a domain and free SSL – Part 2
Conclusion
I hope you enjoyed the guide to install Ghost CMS on an AWS EC2 instance. If so, subscribe to this blog and do share and comment below.
Pingback: Ghost CMS Part 2 - Setting up domain and free SSL - CodeHacks