Create Your Blogging Website Using Ghost on Ubuntu 16.04

By Sajid Qureshi, Alibaba Cloud Tech Share Author. Tech Share is Alibaba Cloud’s incentive program to encourage the sharing of technical knowledge and best practices within the cloud community.

Ghost is a free and open source blogging platform, designed to simplify the process of online publishing for individual bloggers as well as online publications. It is written in JavaScript and uses Node.js as its runtime environment. Ghost uses Markdown syntax in the editor, so you can see how your blog will look like on a live site while you are writing the blog. Ghost is perfect platform for bloggers as it is very clean and lightweight.

In this guide, we will install and configure Ghost on your ubuntu 16.04 Alibaba Cloud Elastic Compute Service (ECS) using Node.js.

Prerequisites

  1. You must have Alibaba Cloud Elastic Compute Service (ECS) activated and verified your valid payment method. If you are a new user, you can get a free account in your Alibaba Cloud account. If you don抰 know about how to set up your ECS instance, you can refer to this tutorial or quick-start guide. Your ECS instance must have at least 1GB RAM and 1 Core processor.
  2. A non root user with sudo access.

Update the System

We recommend you to upgrade all the available packages before installing any new package. To do so, execute the following command.

Install Nginx

Nginx is a web server that we are going to use for installing Ghost. First of all, you will need to install the Nginx server, execute the following command and it will do the job for you.

Next, you will need to start and enable nginx services to automatically start at boot time. Execute the following commands and they will do the job for you.

You can test this Nginx installation through your web browser by visiting server domain name or IP address of your server. You should see a default test page of nginx.

Install MariaDB Database

MariaDB database server will be used to store your ghost data. You will need to install MariaDB server using the following command.

Next, you will need to start and enable MariaDB service to always start up when the server boots. To do so, execute the following command.

We recommend you to make sure this MariaDB installation is fully secured and to do so, execute the following command.

When prompted, answer the questions below by following the guide.

Now you will have to create the database required to store the Ghost data. Login to MySQL shell using the following command and providing the required password when prompted.

Now execute the following query to create a new database.

The above query will create a database named ghost_data. For the database, you can use any name you prefer in the place of ghost_data. Make sure that you use semicolon at the end of each query as a MySQL query always ends with a semicolon. Once the database is created you can create a new user and grant the required permissions to the user for the database.

The above query will create a user with username ghost_user. You can use any preferred username instead of ghost_user. Replace StrongPassword with a strong password.

Now provide the appropriate privileges to your database user over the database you have created. Run the following query to do so.

Now run the following query to immediately apply the changes to the database privileges.

Now you can exit from MySQL prompt using the following command.

Install Node.js

As you know Ghost is based on node.js so, you will need to download and install node.js from its repository. Execute the following command to download node.js.

Once you have downloaded the node.js package, install it using the following command.

Install Ghost

You have installed all the required dependencies to install Ghost. Now, you will need to create a new user to install Ghost. Execute the following command to create a user with a strong password.

You can replace the ghuser with any other username of your choice.

Execute the following command to allow the user to run single commands with superuser privileges by using the sudo (superuser do) command.

Now, login as the new user using the following command.

Next, you will need to create a new Ghost root directory. Run the following command to do so.

Next, you will need to change the ownership rules for your ghost user. To do so, execute the following commands.

If in case you don’t have npm already installed then you can install it using the following command.

Now, change your current directory to ghost root directory and install Ghost. Execute the following commands and they will do the job for you.

Now, Install ghost using the following command.

The above command will begin the Ghost installation. you will be asked to information about your site URL, database username, and other information.

You should see something similar to this.

The ghost installation is finished now. You can access your site through a web browser.

Web Interface

By default Ghost runs on port 2368 so, you will need to type the port number after the URL to access. Open up your favorite web browser and visit http://example.com:2368. You should see a Ghost welcome page.

Setup Nginx As Proxy

As you know by default Ghost runs on port 2368 so you must always type the port number after the YourDomain name to access the Ghost. It makes it a little complicated. You can configure Nginx as a proxy server for Ghost to avoid this URL with the port number.

Create a ghost config file using any text editor like below.

Add the following content to the file.

Save the file and exit from the text editor.

Next, execute the following command to enable the site.

Finally, restart your nginx services using the following command.

Now, you can access your ghost blogs by visiting http://YourDomain.com.

Conclusion

In this article, you have learned how to install and configure Ghost blogging platform on your Alibaba Cloud Elastic Compute Service (ECS) Ubuntu 16.04 server. We hope now you have enough knowledge to publish your blogs on Ghost.

Reference:https://www.alibabacloud.com/blog/create-your-blogging-website-using-ghost-on-ubuntu-16-04_594296?spm=a2c41.12443627.0.0Web Hosting

Follow me to keep abreast with the latest technology news, industry insights, and developer trends.