<div>How to Install & Setup Ghost on Ubuntu Linux</div> 2

How to Install & Setup Ghost on Ubuntu Linux

This post shows how to install and setup Ghost on Ubuntu Linux with Nginx HTTP server. If you are a new user and want to install Ghost on your Ubuntu Linux machine then this article is useful and handy for you.

Ghost is a modern, lightweight and powerful open-source publishing platform that is designed for bloggers who want to turn audience into a business.

Ghost is built on Node.js platform and its design and functioning is very simple and light weight. The new Ghost version includes many new and interesting features such as a new editor, custom structures, support multi-language, dynamic routes, customized homepages and many more.

For more details about Ghost,  please visit its official website.

Ubuntu is a Linux Operating System based on Debian and mostly composed of non-profit(free) and open-source software. It is a complete Linux operating system that compatible with desktops, laptops, server and other devices. Ubuntu is Open Source so it is freely available for both community and professional support.

If you are a learner and looking for a Linux distribution for Learning then Ubuntu Linux Operating System is best for you as a beginning.

How to Install Ghost on Ubuntu Linux

When you are ready, follow the steps below Install & Setup Ghost on your Ubuntu Linux machine:

Step 1 : How to Install Nginx on Ubuntu

Nginx is a lightweight, free and open-source HTTP web server which is also used as a reverse proxy, HTTP cache, IMAP/POP3 proxy server and load balancer. It is perfect to run with ghost publishing platform.

To install Nginx on Ubuntu, run the commands below:

sudo apt update
sudo apt install nginx

Next, run the commands below to stop, start and enable Nginx service to always start up with the server boots:

sudo systemctl stop nginx.service
sudo systemctl start nginx.service
sudo systemctl enable nginx.service

For check if Nginx server is installed or not, simply open your browser and type server IP or hostname.

If browser show result similar like below then Nginx is installed and working properly.


Step 2 : How to Install MariaDB on Ubuntu

MariaDB database server is an open source, fast and secure database server that you can use with Ghost to store its content.

To install MariaDB database server, simply run the commands below:

sudo apt install mariadb-server

Next, you can use the commands below to stop, start and enable MariaDB service  to always start up with the server boots:

sudo systemctl stop mariadb.service
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

Now, run the commands below to secure MariaDB server by creating a root password and disallowing remote root access:

sudo mysql_secure_installation

When you run the above command, it will prompted to answer the questions as show below:

  • Enter current password for root (enter for none): Just press the Enter
  • Set root password? [Y/n]: Y
  • New password: Enter password
  • Re-enter new password: Repeat password
  • Remove anonymous users? [Y/n]: Y
  • Disallow root login remotely? [Y/n]: Y
  • Remove test database and access to it? [Y/n]:  Y
  • Reload privilege tables now? [Y/n]:  Y

For check if MariaDB is installed and working, run the command below:

sudo mysql -u root -p

When prompted, type the root password.

If you see the similar lines as below, then the MariaDB server was successfully installed.

Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 46
Server version: 10.3.29-MariaDB-0ubuntu0.20.04.1 Ubuntu 20.04
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
MariaDB [(none)]>

Step 3: Create Database for Ghost on Ubuntu

Now, we need to create a blank Ghost database and database user. To do that, run the command below to logon to MariaDB database server:

sudo mysql -u root -p

Next, create a database named ghost using command below:


Now, run the command below to create a database user named ghostuser :

CREATE USER 'ghostuser'@'localhost' IDENTIFIED BY 'your_new_password';

Grant the newly created database user to the database by using command below:

GRANT ALL ON ghost.* TO 'ghostuser'@'localhost' WITH GRANT OPTION;

Finally, save your changes and exit:


Step 4 : How to install Node.js on Ubuntu

Node.js is an open source, back-end, cross-platform which is used to build back-end server applications using JavaScript runtime environment. Node.js executes JavaScript code outside a Browser.

Ghost is built on Node.js platform, so we need to download and install Node.js from its repository by using command below:

sudo apt install curl
curl -sL https://deb.nodesource.com/setup_14.x | sudo bash -

After download Node.js packages, run the commands below to install Node.js :

sudo apt install nodejs

After that, run the commands below to include Yarn repository:

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

Next run the command below to install yarn :

sudo apt update
sudo apt-get -o Dpkg::Options::="--force-overwrite" install yarn

Step 5 : Download and Install Ghost publishing platform

To install Ghost, run the command below:

sudo yarn global add ghost-cli

The above command will install the Ghost installation tool.

Next run the command below to create a separate folder for Ghost in the /var/www/ directory :

sudo mkdir -p /var/www/ghost

Now, run the command below to change the ownership of newly created folder to your account :

sudo chown $USER:$USER /var/www/ghost
sudo chmod 775 /var/www/ghost

Change the directory using the command below:

cd /var/www/ghost

next, run the command below to install Ghost:

ghost install

The above command will start the installation process as shown below:

Checking system Node.js version - found v14.18.0
✔ Checking logged in user
✔ Checking current folder permissions
✔ Checking system compatibility
✔ Checking for a MySQL installation
✔ Checking memory availability
✔ Checking free space
✔ Checking for latest Ghost version
✔ Setting up install directory
Downloading and installing Ghost v4.16.0 > Installing dependencies >

Next, provide the database connection that created above:

? Enter your blog URL: http://example.com
? Enter your MySQL hostname: localhost
? Enter your MySQL username: ghostuser
? Enter your MySQL password: [hidden]
? Enter your Ghost database name: ghost
✔ Configuring Ghost
✔ Setting up instance

After that, it will asked that Do you wish to set up Nginx?, Simply type yes as show below :

 Setting up "ghost" system user
ℹ Setting up "ghost" mysql user [skipped]
? Do you wish to set up Nginx? Yes

+ sudo nginx -s reload
✔ Setting up Nginx
? Do you wish to set up SSL? Yes

? Enter your email (For SSL Certificate) admin@example.com
Running sudo command: mkdir -p /etc/letsencrypt
Running sudo command: ./acme.sh --install --home /etc/letsencrypt
Running sudo command: /etc/letsencrypt/acme.sh --issue --home /etc/letsencrypt --domain example.com --webroot /var/www/ghost/system/nginx-root --reloadcmd "nginx -s reload" --accountemail admin@example.com
Running sudo command: openssl dhparam -out /etc/nginx/snippets/dhparam.pem 2048
Running sudo command: mv /tmp/ssl-params.conf /etc/nginx/snippets/ssl-params.conf
✔ Creating ssl config file at /var/www/ghost/system/files/example.com-ssl.conf
Running sudo command: ln -sf /var/www/ghost/system/files/example.com-ssl.conf /etc/nginx/sites-available/example.com-ssl.conf
Running sudo command: ln -sf /etc/nginx/sites-available/example.com-ssl.conf /etc/nginx/sites-enabled/example.com-ssl.conf
Running sudo command: nginx -s reload
✔ Setting up SSL

Next, you will be prompted with some questions as show below, simply choose yes:

 Do you wish to set up Systemd? Yes

✔ Setting up Systemd
? Do you want to start Ghost? Yes
✔ Starting Ghost

After that, it will display a message similar like below:

Running sudo command: /var/www/ghost/current/node_modules/.bin/knex-migrator-migrate --init --mgpath /var/www/ghost/current
✔ Running database migrations
? Do you want to start Ghost? Yes
Running sudo command: systemctl is-active ghost_example-com
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
Running sudo command: systemctl is-active ghost_example-com
✔ Validating config
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking memory availability
Running sudo command: systemctl start ghost_example-com
✔ Starting Ghost
Running sudo command: systemctl is-enabled ghost_example-com
Running sudo command: systemctl enable ghost_example-com --quiet
✔ Starting Ghost
You can access your publication at https://example.com
Next, go to your admin interface at https://example.com/ghost/ to complete the setup of your publication

Ghost uses direct mail by default
To set up an alternative email method read our docs at https://docs.ghost.org/docs/mail-config

To launch Ghost, open your favorite browser and browse for the server hostname or IP address followed by /ghost/ :

welcome to ghost setup ubuntu

click on the Create your account button and Enjoy Ghost publishing platform .

That’s all

If you find any error and issue in above steps , please use comment box below to report.

If our article helps you, please consider buying us a coffee

Thank you for your support.

The post How to Install & Setup Ghost on Ubuntu Linux appeared first on Linux Tutorial Hub.

Leave a Comment

Your email address will not be published. Required fields are marked *