How to Install Ghost CMS on a Webdock Server

Last updated: September 2nd 2024

Ghost is a powerful open-source content management system primarily designed for bloggers and online publications.

I am a WordPress guy myself, but I admit that Ghost provides a refreshing alternative for those looking to host a blog with a streamlined and user-friendly interface that allows you to focus on creating content without being bogged down by complex features.

Ghost comes with built-in SEO tools that enhance your site's visibility on search engines, helping you reach your audience more effectively. You can also choose from customizable themes and various integrations with popular tools to create a site that meets your specific needs.

Moreover, Ghost offers membership and subscription features, making it easy for you to monetize your content. This allows you to engage with your readers while generating revenue. These functionalities are seamlessly integrated into Ghost CMS, streamlining the process compared to WordPress, where setting up plugins and services can be quite complicated.

In this article, I’ll walk you through the steps to install Ghost CMS on a Linux server so you can set up a sleek, modern blog without any hassle.

Why host Ghost on Webdock?

Ghost’s self-hosted version is kind of a hidden fact, thanks to their heavy promotion of managed hosting. Even I was surprised to discover a self-hosted version of the CMS. So, the question arises as to why you should host Ghost on Webdock instead of their managed services.

First, self-hosting Ghost on Webdock VPS gives you complete control over your website, especially the pricing. Its managed services start at $9/mo and have heavy restrictions on storage space, bandwidth, file upload sizes, and more. You don’t have to worry about these restrictions on Webdock (provided you’re on the correct plan for your needs).

Plus you have all the freedom to install your own themes and setup supported integrations, which instead is only available at plans starting at $25/mo on their managed service.

Moreover, you can set custom pricing on Webdock, modifying your hardware exactly to what you need and not paying for wasted resources without the other restrictions imposed on their managed service (plans start at just €/$2.15/mo!)

Another benefit is that you’ll also have full ownership of your data, meaning you won’t have to worry about privacy issues or losing your content due to a service provider’s policies.

Additionally, self-hosting allows for easier scaling as your site grows. If you plan to expand your blog or website, having control over the environment means you can upgrade your resources as needed without restrictions.

Setting up basics

You will need a VPS with a clean OS and no pre-installed services or apps, as Ghost installs and configures everything on our behalf. The VPS should also be running Ubuntu 22.04. As of this guide's writing, Ghost doesn’t support Noble (24.04).

Before we do anything else, I would suggest you start by pointing your server’s IP to your domain via an A or CNAME record as DNS propagation can take several minutes or even hours, rarely. So, this will save a lot of time down the road, especially when setting up SSL.

Login to your server as a sudo user:

$ sudo su

Before installing any software, it’s good practice to update your package lists and upgrade any installed packages:

# apt update && sudo apt upgrade -y

This command updates the package list and upgrades all installed packages on your system without prompts or approvals.

First thing we would need to do is installing NGINX. Usually, I would suggest using Webdock’s famous LEMP stack to get started, but as mentioned earlier, currently, Ghost doesn’t support Noble 24.04, so we will have to install all needed components manually.

# apt install nginx -y

After you set up NGINX, it begins operating right away without needing any additional steps from you.

To confirm that NGINX is installed properly, just enter your server's IP address. You should see a welcome message from NGINX.

We’ll also need to install a database management system. Ghost recommends MySQL 8, so I will go ahead with that:

# apt install mysql-server -y

Once you've installed MySQL, make sure to run the security script that comes with it to enhance your setup's security. You can do this by executing the following command:

# mysql_secure_installation

You will be prompted to answer several questions regarding security settings. Here’s what you can expect:

  • Validate Password Plugin: You can choose whether to enable a password validation plugin. If you enable this, you can set the level of password strength required.
  • Set root password: If not already set, you’ll be prompted to create a password for the MySQL root user.
  • Remove anonymous users: It’s recommended to remove anonymous users for better security.
  • Disallow root login remotely: It’s advisable to disallow root login from remote locations.
  • Remove test database: You should remove the default test database that can be accessed by anonymous users.
  • Reload privilege tables: This option ensures that the changes take effect immediately.

After securing MySQL, you may want to start the MySQL service and enable it to start at boot:

# systemctl start mysql
# systemctl enable mysql

Now you’ll need to add a new database user. Log in to MySQL as the root user:

# mysql -u root -p

Since you’re logged in as a root user, the password here would be the same as your account’s password.

Once you are logged in, you can create a new user by running the following command. Replace new_user with your desired username and user_password with a strong password:

CREATE USER 'new_user'@'localhost' IDENTIFIED BY 'user_password';

Remember this username and password or note it down, you’ll need this later

Then create a new database for Ghost. I’ll keep the name of the database as ghost_db for easy reference:

CREATE DATABASE ghost_db;

Then, assign this database to the user we just created:

GRANT ALL PRIVILEGES ON ghost_db.* TO 'new_user'@'localhost';
FLUSH PRIVILEGES;

Replace the new_user bit with actual one. Then exit the MySQL console by running the exit command.

Ghost also requires Node.js (version 14.x or later). There are various ways to install node.js. But I like to use the NodeSource repository by running:

# curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -

And then installing Nodejs:

# apt install -y nodejs

This also installs npm for you automatically.

Verify the installation:

# node -v
# npm -v

image1.png

Node.js is an event-driven, non-blocking I/O model that makes it ideal for building scalable network applications. Ghost’s architecture leverages this efficiency, allowing quick responses to user requests and handling multiple connections simultaneously.

Installing Ghost CLI

The Ghost Command Line Interface (CLI) is a tool that helps you install and manage your Ghost instance, including:

  • Installation and configuration.
  • Starting, stopping, and restarting your Ghost instance.
  • Updating Ghost to the latest version.
  • Managing the database.

We will discuss this later in the guide. Install Ghost CLI globally using npm:

# npm install -g ghost-cli

This process may take a few minutes. Once installed, Create a directory where your Ghost blog will be located. It’s common to place it in /var/www/:

# mkdir /var/www/ghost

This command will create the said folder in the defined path. Properly organizing your files and directories is crucial for ease of management and security. By placing your Ghost installation in /var/www/ghost, you maintain a clear structure that separates web applications from other system files.

Installing Ghost

Before moving forward, you need to switch to a non-root user to run the next command. There are various ways, but just typing exit switches to a non-root user, so I like to use this method the best:

image2.png

We would also need to change the ownership of the directory /var/www/ghost to the current user and their group. It requires superuser privileges, which is why sudo should be included at the beginning, so the command should look like:

$ sudo chown $USER:admin /var/www/ghost

Then, enter the directory:

$ cd /var/www/ghost

Now that you’re in the Ghost directory and have appropriate authority, you can install Ghost using the Ghost CLI:

$ ghost install

This command will guide you through the installation process and take care of all other auxiliary tasks needed to make Ghost work, such as NGINX setup, Database, SSL, setting up systemd, and more. You’ll be asked to provide some information, so you should add them as needed, such the MySQL user details we added earlier.

Once the setup has run its course and is completed, open your web browser and go to your website + /ghost (for example, https://yourdomain.com/ghost). You will see the Ghost setup screen.

image3.png

You will be prompted to create an administrator account on the setup screen. This account will allow you to access the Ghost admin dashboard to manage your site. You’ll need to provide:

  • Your Name: Enter your full name or a nick name
  • Site Title: Enter the name of your site, which will be displayed at the top of your blog.
  • Your Email Address: This will be used for account verification and notifications.
  • A Password: Choose a strong password to secure your admin account.

After filling in this information, click on the "Create Account" button. You will then be redirected to the admin dashboard, where you will explore the simplistic UI of the CMS.

Managing your Ghost instance

You can manage your Ghost instance using the CLI with various commands -

To check status:

$ ghost ls

To stop Ghost:

$ ghost stop

To start Ghost:

$ ghost start

To restart Ghost:

$ ghost restart

To update Ghost:

$ ghost update

Conclusion

Congratulations! You have successfully installed Ghost CMS on your Linux server! With its user-friendly interface and powerful features, you can now create and manage a professional-looking blog or website tailored to your audience's needs.

Regularly update your instance using the Ghost CLI, explore new themes or plugins, and keep engaging with your audience through quality content. Should you encounter any issues or require further assistance, feel free to reach out to the ever-helpful Ghost forum.

Meet Aayush, a WordPress website designer with almost a decade of experience who crafts visually appealing websites and has a knack for writing engaging technology blogs. In his spare time, he enjoys illuminating the minds around him.

Related articles