This guide provides step-by-step instructions for installing Ghost, a powerful open-source blogging platform, on a CentOS 8 server. Tailored for users interested in the UltraLinux project (https://ultralinux.org/) or those seeking to set up a modern CMS on CentOS, this tutorial uses Nginx as a reverse proxy, MariaDB as the database, and Node.js, following best practices for a production environment. Note that Ghost officially recommends Ubuntu, but this guide ensures compatibility with CentOS 8. For CentOS 7, some steps may differ slightly.
Prerequisites
-
CentOS 8 server with at least 1 GB RAM.
-
Sudo privileges.
-
Internet connection.
-
A domain name with DNS configured (e.g., example.com).
-
Basic terminal familiarity.
Step-by-Step Installation
1. Update the System
Ensure your system is up-to-date:
sudo dnf -y update
sudo reboot
2. Set SELinux to Permissive Mode
Ghost may encounter permission issues with SELinux in enforcing mode. Set it to permissive:
sudo setenforce 0
sudo sed -i 's/^SELINUX=.*/SELINUX=permissive/g' /etc/selinux/config
3. Install EPEL Repository
Add the Extra Packages for Enterprise Linux (EPEL) repository for additional dependencies:
sudo dnf -y install epel-release
4. Install and Configure MariaDB
Ghost requires a database. Install MariaDB:
sudo dnf module install mariadb
sudo systemctl enable --now mariadb
Secure the MariaDB installation:
sudo mysql_secure_installation
Follow prompts to set a root password, remove anonymous users, disable remote root login, and remove test databases.
Create a database and user for Ghost:
mysql -u root -p
CREATE DATABASE ghost;
CREATE USER 'ghost'@'localhost' IDENTIFIED BY 'StrongPassword';
GRANT ALL ON ghost.* TO 'ghost'@'localhost';
FLUSH PRIVILEGES;
QUIT;
Replace StrongPassword with a secure password.
5. Install Node.js
Ghost requires Node.js (version 16.x recommended for stability). Install it:
sudo dnf remove -y @nodejs
curl --silent --location https://rpm.nodesource.com/setup_16.x | sudo bash -
sudo dnf install -y nodejs
Verify Node.js version:
node -v
Ensure it’s around v16.x (e.g., v16.15.0).
Install PM2 to manage Ghost processes:
sudo npm install pm2 -g
6. Install Ghost-CLI
Install the Ghost command-line interface:
sudo npm install -g ghost-cli@latest
Verify installation:
ghost --version
7. Create a Ghost User and Directory
Create a dedicated user for Ghost:
sudo useradd ghostadmin
sudo passwd ghostadmin
sudo usermod -aG wheel ghostadmin
Create the Ghost installation directory (avoid /root or /home to prevent permission issues):
sudo mkdir -p /var/www/ghost
sudo chown ghostadmin:ghostadmin /var/www/ghost
sudo chmod 775 /var/www/ghost
8. Install Ghost
Switch to the ghostadmin user and navigate to the Ghost directory:
sudo su - ghostadmin
cd /var/www/ghost
mkdir blog.example.com
cd blog.example.com
Run the Ghost installer with MySQL:
ghost install --db=mysql
Follow the prompts:
-
Blog URL: Enter http://blog.example.com (replace with your domain).
-
MySQL hostname: localhost
-
MySQL username: ghost
-
MySQL password: Your StrongPassword
-
Ghost database name: ghost
-
Set up Systemd?: Yes
Ignore warnings about non-Ubuntu systems or MariaDB; select Yes to continue. The installer sets up Ghost as a systemd service.
Verify the service:
ghost ls
systemctl status ghost_blog-example-com
9. Install and Configure Nginx
Install Nginx as a reverse proxy:
sudo dnf install @nginx
sudo systemctl enable --now nginx
Create directories for Nginx configuration:
sudo mkdir /etc/nginx/{sites-available,sites-enabled}
Create a configuration file for Ghost:
sudo vi /etc/nginx/sites-available/ghost
Add:
server {
listen 80;
listen [::]:80;
server_name blog.example.com;
root /var/www/ghost/blog.example.com/system/nginx-root;
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:2368;
}
location ~ /.well-known {
allow all;
}
client_max_body_size 50m;
}
Replace blog.example.com with your domain.
Link the configuration:
sudo ln -s /etc/nginx/sites-available/ghost /etc/nginx/sites-enabled/ghost
Update the Nginx configuration file /etc/nginx/nginx.conf to include sites-enabled:
http {
...
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
server_names_hash_bucket_size 64;
}
Test and restart Nginx:
sudo nginx -t
sudo systemctl restart nginx
10. Open Firewall Ports
Allow HTTP and HTTPS traffic:
sudo firewall-cmd --add-service={http,https} --permanent
sudo firewall-cmd --reload
11. Complete Ghost Setup
Access the Ghost admin interface at http://blog.example.com/ghost. Create an admin account to start configuring your blog.
Troubleshooting
-
Ghost-CLI warnings: CentOS is not officially supported, so you may see warnings. Proceed with Yes unless errors occur.
-
Nginx errors: Verify the configuration syntax with sudo nginx -t. Check paths and permissions.
-
MariaDB connection issues: Ensure the database user and password match the ghost database credentials.
-
SPARC considerations: For UltraLinux on SPARC, ensure Node.js and MariaDB are compatible. Use source builds if precompiled packages are unavailable.
-
Service not starting: Check logs in /var/www/ghost/blog.example.com/content/logs/ or use ghost doctor.
Conclusion
You’ve successfully installed Ghost on CentOS 8 with Nginx and MariaDB. This setup is robust for blogging and content management, even on non-standard hardware like SPARC for UltraLinux users. For further assistance, consult the UltraLinux FAQ (https://ultralinux.org/faq.html), Ghost documentation (https://ghost.org/docs/), or community mailing lists.