Install Ghost on Linode as a Second Website

Ghost is a one of the best alternatives to Wordpress for blogging and super easy to host alongside your main website on Linode with the setup taking just a few minutes.


3 min read
Install Ghost on Linode as a Second Website

Ghost is an amazing blogging platform based on NodeJS and in my opinion is a better platform than Wordpress in case you need a simple blog or a static website.

In this setup I am using a LEMP (Linux, Nginx, MySQL, PHP) stack on Ubuntu 18.04 LTS on Linode's cheapest Nanode plan. Ghost being a very lightweight CMS, you can even host it along with other websites with the help of Nginx server blocks (like Apache has virtual hosts).

Lets Begin

  1. Create a new non-root user if you don't have one already. You will have to cuse a non-root user as Ghost CLI doesn't permit installation directly by a root user. I am creating a user "priyansh" and adding it to the sudo group for sudo privileges.
adduser priyansh
usermod -aG sudo priyansh

2.  Upgrade your system and install build-essential:

sudo apt update && sudo apt upgrade
sudo apt install build-essential

3. Install Node.js and NPM. Then we also install Ghost-CLI which will make our task of installing ghost super easy.

curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt install nodejs
sudo npm install -g [email protected]

Install Ghost

We will be installing it in the /var/www/priyan.sh directory. This is just one of our multiple websites on this server. First we will create the directory for our desired website. Then we switch the directory permissions to the "priyansh" user. Additionally we change the permissions of the directory to provide it the proper permissions for hosting our ghost blog.

sudo mkdir -p /var/www/priyan.sh
sudo chown priyansh:priyansh /var/www/priyan.sh
sudo chmod 775 /var/www/priyan.sh

Navigate to the root /var/www/priyan.sh directory and check if the directory is empty.

cd /var/www/priyan.sh
ls -a

Now we proceed to install ghost. Answer each question with the help of the Ghost documentation.

  • Blog URL -  https://priyan.sh
  • MySQL hostname - localhost
  • MySQL username - root
  • MySQL password - password (your MySQL password)
  • Ghost database name - ghost
  • Nginx setup - Yes
  • SSL setup - Yes
  • "ghost" mysql user - Yes
  • Systemd setup - Yes
  • Start Ghost - Yes

For the Nginx configuration, it should set everything automatically. In case you face any issues, you can copy the following Nginx configuration. You can edit your configuration at "/etc/nginx/sites-available". There will be two files for HTTP and HTTPS. You have to edit it accordingly.

server {
    listen 80;
    listen [::]:80;

    server_name priyan.sh www.priyan.sh;
    root /var/www/priyan.sh;

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass http://127.0.0.1:2369;

    }

    location ~ /.well-known {
        allow all;
    }

    client_max_body_size 50m;
}

After making the desired changes, delete any files for that website in your "/etc/nginx/sites-enabled" directory and then create a new symlink by using the following commands. Then restart Nginx.

sudo rm /etc/nginx/sites-enabled/priyan.sh.conf
sudo rm /etc/nginx/sites-enabled/priyan.sh-ssl.conf
sudo ln -s /etc/nginx/sites-available/priyan.sh.conf /etc/nginx/sites-enabled/priyan.sh.conf
sudo ln -s /etc/nginx/sites-available/priyan.sh-ssl.conf /etc/nginx/sites-enabled/priyan.sh-ssl.conf
sudo systemctl restart nginx

This should set up Nginx for your Ghost blog. Additionally I recommend to restart ghost as well after any changes to avoid errors.

cd /var/www/priyan.sh
ghost restart

Final Setup

Now we can head to our admin area by adding "/ghost" after your website address. You will find your new blog's welcome screen.

ghost welcome screen

Enter your email, name, password, and website title to create a new admin user:

create a new admin user in ghost

Navigate to the Ghost admin area and get used to the features. Your blog is ready!

Troubleshooting

You can navigate to your ghost installation directory "/var/www/priyan.sh" as the non root user "priyansh" and use the ghost cli to troubleshoot.

ghost doctor

In case you face any trouble, you can use the ghost community forums or drop me a comment!

Related Articles

🎉 You've successfully subscribed to Get Eccentric | Priyansh Kothari!
OK