‍In today’s digital age, having a powerful and user-friendly blogging platform is essential for individuals and online publications alike. Ghost, a free and open-source platform, is designed to simplify the process of online publishing. In this article, we will guide you through the installation process of Ghost on RockyLinux 8, enabling you to create and manage your own blog with ease.

Prerequisites

Before we begin, make sure you have the following prerequisites in place:

  1. A server running RockyLinux 8.
  2. Root access to the server.
  3. Basic knowledge of the Linux command line.

Step 1: Update the System

The first step in installing Ghost on RockyLinux 8 is to update the system. This ensures that you have the latest security patches and software updates. To update the system, log in as the root user and run the following command:

yum update -y

Step 2: Set SELinux to Permissive Mode

Next, we need to set SELinux to permissive mode. SELinux is a security mechanism that provides an additional layer of protection for your system. However, it can sometimes interfere with the installation process. To set SELinux to permissive mode, run the following command:

setenforce 0
sed -i 's/^SELINUX=.*/SELINUX=permissive/g' /etc/selinux/config

Step 3: Add EPEL Repository

To install additional packages required for Ghost, we need to add the EPEL repository. EPEL (Extra Packages for Enterprise Linux) provides a collection of additional software packages that are not included in the default RockyLinux repositories. To add the EPEL repository, run the following command:

dnf -y install epel-release

Step 4: Create a Sudo User

To enhance the security of your system, it is recommended to create a separate sudo user for managing Ghost. This user will have administrative privileges and can perform tasks that require root access. To create a new sudo user, use the adduser command:

adduser ghostadmin

Next, set a password for the new user:

passwd ghostadmin

To add the user to the wheel group, which grants sudo privileges, run the following command:

usermod -aG wheel ghostadmin

Switch to the new user account using the su command:

su - ghostadmin

Step 5: Install and Configure MariaDB

Ghost requires a database server to store its data. In this installation guide, we will use MariaDB, a popular and reliable database server. To install MariaDB, run the following commands:

sudo yum install mariadb-server mariadb

After the installation is complete, enable and start MariaDB:

sudo systemctl enable mariadb
sudo systemctl start mariadb

To secure your MariaDB installation, run the following command:

sudo mysql_secure_installation

Follow the prompts to set a root password, remove anonymous users, disallow remote root login, and remove the test database. It is recommended to answer “Y” to all prompts unless you have specific requirements.

Step 6: Install Latest Version of Node.js

Ghost is built on Node.js, a JavaScript runtime. To install Node.js on RockyLinux 8, we will use the NodeSource repository. Run the following commands to install Node.js:

sudo curl -sL https://rpm.nodesource.com/setup_16.x | sudo -E bash -
sudo yum install -y nodejs

After the installation is complete, verify the Node.js version by running:

node --version

Step 7: Install and Configure NGINX

NGINX is a high-performance web server that will act as a reverse proxy for Ghost. To install NGINX, run the following command:

sudo yum install nginx

Once the installation is complete, start and enable NGINX:

sudo systemctl start nginx
sudo systemctl enable nginx

Step 8: Configure NGINX for Ghost

To configure NGINX for Ghost, we need to create a server block configuration file. Create a new file using your preferred text editor:

sudo vi /etc/nginx/conf.d/ghost.conf

Add the following configuration to the file:

server {
listen 80;
server_name example.com;

location / {
proxy_pass http://localhost:2368;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}

Replace example.com with your actual domain name. Save and exit the file.

Next, test the NGINX configuration for any syntax errors:

sudo nginx -t

If there are no errors, reload NGINX to apply the changes:

sudo systemctl reload nginx

Step 9: Install Ghost-CLI

Ghost-CLI is a command-line interface tool that makes installing and managing Ghost installations easy. To install Ghost-CLI, run the following command:

sudo npm install -g ghost-cli@latest

Once the installation is complete, verify the Ghost-CLI version by running:

ghost --version

Step 10: Create a Ghost Directory

Create a directory to store your Ghost installation files:

sudo mkdir -p /var/www/example.com

Replace example.com with your actual domain name.

Change the ownership of the directory to the ghostadmin user:

sudo chown ghostadmin:ghostadmin /var/www/example.com

Set the appropriate permissions for the directory:

sudo chmod 775 /var/www/example.com

Step 11: Install Ghost

Navigate to the Ghost directory:

cd /var/www/example.com

Install Ghost using the Ghost-CLI:

ghost install

Follow the prompts to configure your Ghost installation.

Step 12: Install SSL Certificate

To secure your Ghost installation with SSL, you can use Let’s Encrypt and Certbot. First, install Certbot and the Certbot NGINX plugin:

sudo dnf install certbot python3-certbot-nginx

Once the installation is complete, run the following command to generate and install the SSL certificate:

sudo certbot --nginx

Follow the prompts to obtain and install the SSL certificate for your domain.

Conclusion

Congratulations! You have successfully installed Ghost on RockyLinux 8. You can now access the Ghost CMS dashboard by visiting your domain. Create your first Ghost administrator account and start publishing your blogs. Remember to regularly update your Ghost installation and secure it for optimal performance.

Shape.host offers reliable and scalable cloud hosting solutions, including Cloud VPS, to empower businesses with efficient online publishing platforms. Explore Shape.host’s services to enhance your blogging experience and take your online presence to new heights.