Setting up a stand-alone Ghost server can be difficult at times and outright frustrating at others. In the end, I managed to install Ghost 5.76.2 on Ubuntu 22.04 with apache rather than nginx because my hosting environment needs apache2 for various services. That said, I still have not been able to integrate Sendgrid yet for SMTP but I'm still working on that. I am using Gmail for SMTP and that set up is pretty straight forward and did not cause me any problems.
Before proceeding, you will need to install apache2 and mysql and create your database and database user, directions for which can be found in many places on the internet.
I already had node install on the server, but it was 21.x and the current version of Ghost requires node 18.x. I did not need 21.x so I removed it first:
sudo apt remove nodejs npm
Next, update aptitude package manager for the version of node that we need:
curl -sL https://deb.nodesource.com/setup_18.x -o nodesource_setup.sh
Execute the shell script:
sudo bash nodesource_setup.sh
Lastly, install nodejs using aptitutde:
sudo apt install nodejs
You can confirm your install worked properly by checking the version number:
node -v ; npm -v
Lastly, we need the ghost shell client:
sudo npm install ghost-cli@latest -g
Create a User and Establish the Software Environment
We need a user that will own the ghost environment and execute the ghost service.
sudo groupadd ghost
sudo useradd -g ghost -G sudo ghost
You can install ghost wherever you like and for this demo we install into /opt/nodejs/ghost
sudo mkdir -p /opt/nodejs/ghost/
sudo chown -R ghost:ghost /opt/nodejs/ghost/
sudo chmod 775 .
The official documentation suggest that you login as the ghost user:
sudo su -
but I did not have much luck with that, where the installer tried to write to /home/user for some reason and I just installed as my user. Your user will have to be a member of the ghost user's group or just make the directory world read/write (chmod 777) and then install:
When prompted, enter the values for the site:
? Enter your blog URL: https://example.com
? Enter your MySQL hostname: localhost
? Enter your MySQL username: ghost_prod
? Enter your MySQL password: [hidden]
? Enter your Ghost database name: ghost_prod
Since nginx is not installed, the installer will skip those configuration steps. When prompted about systemd, however, choose 'y':
? Do you wish to set up Systemd? Yes
That will allow you manage the ghost service through systemd and it will start the service at boot time.
Once complete, you can check that the service is running on port 2368:
sudo lsof -i :2368
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 9974 ghost 23u IPv4 79569 0t0 TCP localhost.localdomain:2368 (LISTEN)
Lastly, execute the ghost doctor to check on your install statusho:
✔ Checking system Node.js version - found v18.19.0
✔ Checking logged in user
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
✔ Checking system compatibility
+ sudo systemctl is-active ghost_fire-carthage-edu
Instance is currently running
ℹ Validating config [skipped]
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking memory availability
✔ Checking binary dependencies
✔ Checking free space
✔ Checking systemd unit file
✔ Checking systemd node version - found v18.19.0
If you see the following message about the ownership of the install directory:
Your user does not own the directory /path/to/ghost. This might cause permission issues.
You can change the ownership of the install directory to be owned by your user and the ghost user group:
sudo chown user:ghost .
Lastly, have a look at the configuration file and make and updates or corrections that you need to do.
We will be working on this file going forward when we set up the SMTP connection but for now that should be it for the ghost installation itself.