This guide will demonstrate how to Install Ghost CMS on Debian 11 / Debian 10 Linux distribution. Ghost is an open source publishing platform which is beautifully designed, easy to use, and free for everyone. It has full support for Markdown and provides an easy to use the web interface for administration purposes.
For CentOS / RHEL: Install and Configure Ghost CMS on CentOS / RHEL 7/8
Setup Requirements
For this setup, the basic requirements are:
- Debian 11 / Debian 10 Linux server
- Nginx Web Server
- FQDN – e.g blog.example.com (have DNS A record pointing to your server FQDN)
- Node.js installed
- MySQL / MariaDB Database Server
- ghost user – Non-root user to manage it
Let’s start installation of Ghost on Debian 11 / Debian 10 Linux machine.
Step 1: Install and Configure MySQL / MariaDB database server
Install a database server for Ghost CMS. This can either be MySQL or MariaDB database server.
sudo apt update
sudo apt install mariadb-server
When done, Create the database for ghost blog you plan to add:
$ sudo mysql -u root -p
CREATE USER ghostcms@localhost IDENTIFIED BY "StrongDBPassword";
CREATE DATABASE ghostcms;
GRANT ALL ON ghostcms.* TO ghostcms@localhost;
FLUSH PRIVILEGES;
QUIT
Step 2: Install Nginx Web Server on Debian
Next is the installation of Nginx
sudo apt -y install nginx
Nginx systemd service is started automatically after installation:
$ systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2022-03-21 20:01:19 UTC; 31s ago
Docs: man:nginx(8)
Process: 3565 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 3566 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 3755 (nginx)
Tasks: 3 (limit: 2340)
Memory: 4.4M
CPU: 23ms
CGroup: /system.slice/nginx.service
├─3755 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
├─3758 nginx: worker process
└─3759 nginx: worker process
Mar 21 20:01:19 debian-bullseye-01 systemd[1]: Starting A high performance web server and a reverse proxy server...
Mar 21 20:01:19 debian-bullseye-01 systemd[1]: Started A high performance web server and a reverse proxy server.
Step 3: Add User for Ghost administration
Add user called ghostadmin
sudo adduser ghostadmin
sudo usermod -aG sudo ghostadmin
Step 4: Install Node.js on Debian 11/10
Configure Node.js 16 apt repository.
sudo apt -y install curl dirmngr apt-transport-https lsb-release ca-certificates
curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
Install Node.js on Debian once the repository has been configured:
sudo apt install -y nodejs
Confirm Node version
$ node -v
v16.14.2
Step 5: Install Ghost-CLI on Debian 11 / Debian 10
We now need to install the package ghost-cli which provides ghost command.
sudo npm i -g ghost-cli
Step 6: Create a new folder for Ghost Data
Please note that:
- Installing Ghost in the /root folder won’t work and result in a broken setup!
- Installing Ghost in your /home/{user} folder won’t work and result in a broken setup!
- Please only use /var/www/{folder} because it has the right permissions.
So let’s create this directory:
sudo mkdir -p /var/www/ghost
sudo chown ghostadmin:ghostadmin /var/www/ghost
sudo chmod 775 /var/www/ghost
Step 7: Install Ghost on Debian 11 / Debian 10
Create Ghost CMS directory.
sudo su - ghostadmin
cd /var/www/ghost
mkdir blog.example.com
cd blog.example.com
Run the command below to install ghost:
$ ghost install
✔ Checking system Node.js version
✔ Checking logged in user
✔ Checking current folder permissions
✔ Checking operating system compatibility
✔ Checking for a MySQL installation
✔ Checking memory availability
✔ Checking for latest Ghost version
✔ Setting up install directory
✔ Downloading and installing Ghost v4.41.0
✔ Finishing install process
? Enter your blog URL: http://blog.example.com
? Enter your MySQL hostname: localhost
? Enter your MySQL username: ghostcms
? Enter your MySQL password: [hidden] StrongDBPassword
? Enter your Ghost database name: ghostcms
✔ Configuring Ghost
✔ Setting up instance
sudo useradd --system --user-group ghost
sudo chown -R ghost:ghost /var/www/ghost/blog.example.com/content
✔ Setting up "ghost" system user
? Do you wish to set up "ghost" mysql user? Yes
MySQL user is not "root", skipping additional user setup
ℹ Setting up "ghost" mysql user [skipped]
? Do you wish to set up Nginx? Yes
✔ Creating nginx config file at /var/www/ghost/blog.example.com/system/files/blog.example.com.conf
sudo ln -sf /var/www/ghost/blog.example.com/system/files/blog.example.com.conf /etc/nginx/sites-available/blog.example.com.conf
sudo ln -sf /etc/nginx/sites-available/blog.example.com.conf /etc/nginx/sites-enabled/blog.example.com.conf
sudo nginx -s reload
✔ Setting up Nginx
? Do you wish to set up SSL? No
ℹ Setting up SSL [skipped]
? Do you wish to set up Systemd? Yes
✔ Creating systemd service file at /var/www/ghost/blog.example.com/system/files/ghost_blog-example-com.service
sudo ln -sf /var/www/ghost/blog.example.com/system/files/ghost_blog-example-com.service /lib/systemd/system/ghost_blog-example-com.service
sudo systemctl daemon-reload
✔ Setting up Systemd
? Do you want to start Ghost? Yes
sudo systemctl is-active ghost_blog-example-com
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
sudo systemctl is-active ghost_blog-example-com
✔ Validating config
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking memory availability
sudo systemctl start ghost_blog-example-com
✔ Starting Ghost
sudo systemctl is-enabled ghost_blog-example-com
sudo systemctl enable ghost_blog-example-com --quiet
✔ Enabling Ghost instance startup on server boot
Ghost uses direct mail by default. To set up an alternative email method read our docs at https://ghost.org/mail
Ghost was installed successfully! To complete setup of your publication, visit:
http://blog.example.com/ghost/
This will install and start your blog in production mode using MySQL as the default database. You can Agree to setup Let's Encrypt SSL
. If your server has a valid domain name and Public IP Address.
Nginx configuration files will be placed under: /etc/nginx/sites-enabled/
Check service status:
$ systemctl status ghost_blog-example-com
● ghost_blog-example-com.service - Ghost systemd service for blog: blog-example-com
Loaded: loaded (/var/www/ghost/blog.example.com/system/files/ghost_blog-example-com.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2022-01-30 17:06:48 EAT; 34min ago
Docs: https://docs.ghost.org
Main PID: 19723 (ghost run)
Tasks: 18 (limit: 4915)
CGroup: /system.slice/ghost_blog-example-com.service
├─19723 ghost run
└─19734 /usr/bin/node current/index.js
Ghost Cheats:
Logs dir: /content/logs/
$ ghost start: Start ghost
$ ghost restart: Restart ghost
$ ghost run: Test if the ghost can start successfully
$ ghost uninstall: Re-install ghost
$ ghost update: Upgrade ghost
$ ghost update — force: Force upgrade if there are errors
$ ghost update –rollback: Revert to the earlier version if an upgrade fails
$ sudo npm i -g [email protected]: Upgrade Ghost-CLI
$ ghost ssl-renew: Renew ssl certificate
$ ls ./system/files/*.conf: System configuration files
$ ghost setup nginx: Manually Setup nginx
$ ghost setup nginx ssl: Setup nginx with SSL
Accessing Ghost Admin interface on Debian 11 / Debian 10
Your setup is now ready, access Ghost web admin interface where you can upload themes, change settings and write content using markdown syntax.
To complete setup of your publication, visit:
Create your first Ghost administrator/publisher account.
You have successfully installed Ghost CMS on Debian 11 / Debian 10. Also check other guides on web hosting and documentation.