This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘
sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Ghost Content Management System on Rocky Linux. 9.
- A server running one of the following operating systems: Rocky Linux 9.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
non-root sudo useror access to the
root user. We recommend acting as a
non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.
Install Ghost on Rocky Linux 9
Step 1. The first step is to update your system to the latest version of the package list. To do so, run the following commands:
sudo dnf check-update sudo dnf install dnf-utils
Step 2. Installing Nginx Web Server.
By default, Nginx is not available on Rocky Linux 9 base repository. Now run the following command below to add Nginx stable repository to your system:
sudo tee /etc/yum.repos.d/nginx-stable.repo<<EOF [nginx-stable] name=nginx stable repo baseurl=http://nginx.org/packages/centos/9/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://nginx.org/keys/nginx_signing.key module_hotfixes=true EOF
Now, run the following command to install the latest stable version of Nginx to your server:
sudo dnf update sudo dnf install nginx
Once the installation is done, start the Nginx service and enable it to automatically start on reboot all in one go with:
sudo systemctl enable --now nginx
To verify that the latest version of Nginx has been installed, run:
By default, Nginx listens on ports 80 and 443. If any firewall is installed and configured on your server, then you will need to allow both ports via firewalld. You can allow them with the following command:
sudo firewall-cmd --permanent --zone=public --add-service=http sudo firewall-cmd --permanent --zone=public --add-service=https sudo firewall-cmd --reload
You can verify by listing the current firewall settings:
sudo firewall-cmd --permanent --list-all
In addition, we set up SELinux now allows Nginx to connect to the network:
sudo setsebool -P httpd_can_network_connect 1
For additional resources on installing Nginx, read the post below:
Step 3. Installing Node.js on Rocky Linux 9.
By default, Node.js is not available on Rocky Linux 9 base repository. Now run the following command below to add the NodeSource repository to your system:
curl -sL https://rpm.nodesource.com/setup_16.x | bash -
Next, install the latest Node.js version with the following command:
sudo dnf install nodejs
Verify the installed Node.js version using the command:
To verify the NPM version, run the following command:
For additional resources on installing Node.js, read the post below:
Step 4. Installing MariaDB Database.
By default, MariaDB is available on Rocky Linux 9 base repository. Now run the following command below to install the latest stable version of MariaDB to your system:
sudo dnf install mariadb-server mariadb
Once the installation is complete, start the MariaDB service and enable it to automatically start on boot by running the following command below:
sudo systemctl enable mariadb --now sudo systemctl start mariadb sudo systemctl status mariadb
To check the version of MariaDB installed, run the command below:
By default, MariaDB is not hardened. You can secure MariaDB using the
mysql_secure_installation script. you should read and below each step carefully which will set a root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MariaDB:
Configure it like this:
- Set root password? [Y/n] y - 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
You can now try to access the database with the set root user password:
mysql -u root -p
Now create a database user, database, and assign control over the created database to the user:
MariaDB [(none)]> CREATE DATABASE ghostdb; MariaDB [(none)]> CREATE USER 'ghostuser'@'localhost' IDENTIFIED BY 'your-strong-password'; MariaDB [(none)]> GRANT ALL ON ghostdb.* TO 'ghostuser'@'localhost'; MariaDB [(none)]> FLUSH PRIVILEGES; MariaDB [(none)]> EXIT;
For additional resources on installing MariaDB, read the post below:
Step 5. Installing Ghost on Rocky Linux 9.
Run the following command to install the Ghost-CLI tool. Ignore any warnings you receive during the process:
sudo npm install ghost-cli@latest -g
Next, create the Ghost root directory:
sudo mkdir -p /var/www/html/ghost
Set the ownership and directory permissions:
sudo chown $USER:$USER /var/www/html/ghost sudo chmod 755 /var/www/html/ghost
In your terminal, navigate to the directory and run it using the following command:
cd /var/www/html/ghost ghost install
During the installation, the CLI tool will ask a number of questions to configure:
- At the time of writing this tutorial, Ghost-CLI doesn’t support any other OS apart from Ubuntu. It will ask if you still want to continue with the installation. Press Y to continue.
- Blog URL: Enter your complete blog URL along with the HTTPS protocol. (
- MySQL Hostname: Press Enter to use the default value
localhostsince our Ghost install and MySQL are on the same server.
- MySQL Username: Enter
rootyour MySQL username.
- MySQL Password: Enter your root password created before.
- Ghost database name: Give a name for your Ghost database. (
- Sudo password: Enter your system’s
sudopassword to perform elevated commands.
- Set up a ghost MySQL user?: The installer will ask if you want to create a separate MySQL user for Ghost. Press Y to proceed.
- Set up Nginx?: Usually, Ghost-CLI detects your Nginx installation and automatically configures it for your blog. But as of now, it can’t detect our Nginx install. Hence, the installer will automatically skip this step. We will configure Nginx manually.
- Set up SSL?: Since it skipped over the Nginx configuration, the CLI tool will also skip setting up an SSL.
- Set up systemd?: Ghost will ask if you want to set up a system service for Ghost. Press Y to proceed.
- Start Ghost?: Press Y to start your Ghost installation. The service will start but we will need to configure Nginx and SSL to make it work.
Step 6. Installing Certbot.
We generate the SSL Certificate from Let’s Encrypt manually by running the below commands:
sudo dnf install certbot python3-certbot-nginx
Then, run the following command to generate certificates with the Nginx:
sudo certbot --nginx
Step 7. Accessing Ghost Web Interface.
Once successfully installed, open your web browser and access the Ghost admin interface using the URL
https://ghost.your-domain.com. You should see the following page:
Congratulations! You have successfully installed Ghost. Thanks for using this tutorial for installing Ghost Content Management System on your Rocky Linux 9 system. For additional help or useful information, we recommend you check the official Ghost website.