[Ubuntu] How to Install Ghost


Introduction

Ghost is a fully open source, hackable platform for building and running a modern online publication. It is a light-weight. It is fully customizable, with many themes available. Ghost user interface is very simple and straightforward making it great for beginners as well as advanced users.

This tutorial will walk you through how to install Ghost on Ubuntu.


Requirements

In this tutorial we will be using Ubuntu 16.04, however you should be able to use all our offered Ubuntu and Debian versions.

In Time4VPS you are able to install Ubuntu 16.04 template really easy and fast, only with few mouse clicks:
  1. Login to the Clients Portal;
  2. Select at the top of menu the "My Services > VPS" tab;
  3. Press the "Manage" button at the service table;
  4. Press the "Install OS" button;
  5. Choose Ubuntu 16.04 operating system, agree with warning and press "Continue";
  6. Wait for 5-10 minutes and refresh VPS management page.

Updating System

First things first. Like always, first of all, we recommend to update and upgrade your server.
apt-get update
apt-get upgrade -y


Installing Node.js

There is at least few quite good ways to install Node.js on the server, so you are able to use any of them. However if you do not have your own preferable way and do not want to configure it by yourself you can simply run these commands:

curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
Note: If you got error "-bash: curl: command not found" you need to install curl. Run this command to do that:
apt-get install curl

More information and instructions on how to configure it, choose version and so on can be found in this tutorial.


Install and Configure nginx

Now you need to install and configure nginx. First of all we need to stop Apache as it's installed and ran by default:
/etc/init.d/apache2 stop
Now we can install nginx:
apt install nginx
Create this file:
nano /etc/nginx/conf.d/ghost.conf
And paste the following configuration code into the file. Change server_hostname to your blog’s domain.
server {
  listen 80;
  server_name server_hostname;
  location / {
      proxy_set_header   X-Real-IP $remote_addr;
      proxy_set_header   Host      $http_host;
      proxy_pass         http://127.0.0.1:2368;
  }
}
Restart nginx:
systemctl restart nginx


Installing Ghost

To begin, download the latest release of Ghost. At this moment (26th May, 2017) latest version is 0.11.9. If you want to host multiple Ghost blogs on same VPS, each Ghost instance must be running on a separate port. Make webroot directory:
mkdir -p /var/www/
Create a Ghost user:
adduser ghost
Download and unzip Ghost:
cd /var/www
wget https://ghost.org/zip/ghost-latest.zip
unzip ghost-latest.zip -d ghost
chown -R ghost:ghost /var/www/ghost/
rm ghost-latest.zip
Switch to the ghost user:
su - ghost
Install Ghost:
cd /var/www/ghost
npm install --production
Configure Ghost by changing url property of production object inside of config.js file:
cp config.example.js config.js
nano config.js
Edit the url section, replacing example.com with the URL or IP address of your server.

Install the npm package forever, which will ensure that Ghost runs continuously:
npm install -g forever
Run Ghost in production mode using forever:
NODE_ENV=production forever start index.js
Now that Ghost is running, you should be able to see your blog in a web browser by visiting the domain or IP address you entered into your configuration files.


Conclusion

Now you have installed, configured and ready to be used Ghost application on your server. Go to your website, setup login and other details and that's it, you are ready to blog!



Tagged:
Sign In or Register to comment.