Ghost is a free and open-source blogging platform built with Node.js. As a fast, modern WordPress alternative, Ghost is focused completely on professional publishing. If you only want to publish content on the web and don’t need the additional features offered by WordPress, then Ghost is a great choice for you.
In this post, we will discuss how to install Ghost, an open-source CMS, using RunCloud.
Let’s get started!
Create A New User
Ghost CLI needs sudo privileges, so instead of running your site as a root user, we recommend creating a new user with these sudo privileges. This can be done by running commands in the terminal – but it’s much easier to do it within the RunCloud dashboard.
To create a new user, go to the RunCloud dashboard and open the “System User” menu.
Once opened, click on “Add New System User” to create a new user. Give it a descriptive name and a secure password. Make sure to check the box to allow the execution of privileged commands.
After this, click “Save System User” and continue with the installation process.
Create A New Database
After creating the system user, the next step is to create a new database and database user. To do this, go to the “Database” menu under your server in the RunCloud Dashboard to create a new database user. Give this database user a suitable name and a secure password, and make a note of these credentials as they will be needed later during the installation.
After creating the database user, create a new database and grant permission to the user that we just created. Save the changes before moving on to the next step.
Create An Empty Web App
After you have created the user, go to the “Web Applications” tab and make a new web application on your server. Choose the “Empty Web App” option and give your application a suitable name. Don’t forget to change the owner of the application – instead of using the default RunCloud user, we will make the user account that we just created the owner of the web application.
After configuring the application owner, you can set up the domain of the application and configure the DNS records manually on your DNS registrar’s site. If you are using RunCloud’s Cloudflare integration, you can take advantage of the automatic DNS update functionality.
It is also possible to install Ghost using RunCloud’s test domain. If you want to follow along with this tutorial without having to set up your own domain or subdomain, then use the RunCloud test domain.
For “Web Application Stack“, we recommend choosing “Native Nginx + Custom Config” for installing Ghost CMS, then click “Deploy” to finish the set-up process. That said, if your server runs on OpenLiteSpeed – we’ve included notes on steps that are different in this guide.
After creating the app, go to the settings page and scroll down to the “Linked Database” section. From the dropdown menu, select the database that we just created. Don’t forget to click “Update Linked Database” in order to save the changes.
Installing Ghost-CLI
In the previous step, we created a dummy web application in the RunCloud dashboard, as this helps us perform administrative tasks such as monitoring the logs from the RunCloud dashboard. Now we will use Ghost-CLI, a command-line tool, to install and configure Ghost CMS and replace that dummy application.
We will install the Ghost-CLI as the owner of the web application to avoid any permission conflicts. To do this, log into your server as the system user assigned to the web application – you can either do this via SSH or use the su (switch user) command.
# Method 1
ssh ghostcms-user@<youripaddress>
# Method 2
ssh root@<youripaddress>
sudo su ghostcms-user
After logging into the server, navigate to the root directory of your web application using the following command. Replace the “<path to root>” with your path – you can find this in the RunCloud dashboard.
cd <path to root>
Once you are in the correct directory you can run the following commands to remove the default “index.html” file and begin the installation.
rm index.html
sudo npm install ghost-cli@latest -g
After the installation is complete, you can run “ghost version” in your terminal to check the version of Ghost-CLI, and ensure that the CLI works as expected.
Checking Node.js version
Ghost CMS needs Node.js to function properly. At the time of writing, the recommended node version was 18; refer to the official website to see the recommended node version. Execute the following command to see the version of node installed on your server.
node -v
In the above screenshot, the first number in v18.18.0
indicates the major version number of the software. The major version number reflects the level of compatibility and functionality of the software. The other numbers after the dot (.) are minor version numbers or patch numbers. They do not affect the compatibility or functionality of the software as much as the major version number. Therefore, they can be ignored if you are only interested in the major version number.
Note: If you created your server before 27 September 2023, you might need to update the node version on your server manually. Refer to our guide for updating node on your RunCloud server to learn how to do this.
Installing Ghost CMS
After installing Ghost-CLI, you can run the following command to start the Ghost CMS installation.
ghost install
During the installation, follow the instructions on the screen, and enter the necessary information to proceed with installation. When asked for hostname
, make sure to enter 127.0.0.1
, using the default value causes the Ghost CMS to use IPv6 address and leads to ECONNREFUSED ::1:3306
error at a later stage in the installation. When asked, “Do you wish to set up Systemd”, please enter “Y”, and when prompted, “Do you wish to start Ghost”, enter “Y” again.
If you follow the instructions correctly you will get a message that the installation was successful. However, when you visit your site you will see a 404 error message. This is because we skipped the Nginx setup during installation. We can configure this manually to fix it.
Before we set up the server proxy, we need to know which port Ghost will use for this website. Run the following command to get the details of your web application:
ghost ls
The above command will show an output that looks like this:
In the example above, the port number is 2368. Note down this port number.
Setting Up A Proxy
You need to configure your server to redirect all the incoming traffic to the given port. This step is different for Nginx and OpenLiteSpeed servers. If you are not sure which server is installed on your machine, you can check this in the RunCloud dashboard and then follow along the instructions corresponding to your server.
For Nginx
Go back to the RunCloud dashboard, open your web application, and go to the Nginx Config menu. Click the “Create Config” button and follow the steps below.
- For the “Type” option, make sure to select the value “location.root”.
- For the “Config Name” option, you can use the value “ghost”.
- For “Config Content” textarea, copy and paste the text below. Make sure to change XXXX with the port number that we noted down earlier.
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:XXXX;
You can click “Run and Debug” to see if there are any issues with this custom config. Click the “Add Config” button to finish it.
For OpenLiteSpeed
In the RunCloud dashboard, open the empty web application that we created in the Create An Empty Web App step and look for the “LiteSpeed Config” in the side menu to open the configuration file.
We need to edit a few lines in this file. Firstly, note down the name of the extprocessor – we will use this later.
Next, disable the existing configuration by adding # before the type and address line.
After that, add the following lines below the commented lines. Don’t forget to change xxxx with the port number that we noted down earlier.
type proxy
address localhost:xxxx
At this stage, your configuration file should look like this:
Next, scroll down and add the following code snippet to your configuration file. Be careful not to paste it in the middle of an existing config block. Replace the <my-ghost> with the name of the extprocessor that we noted down earlier.
context / {
type proxy
handler <my-ghost>
addDefaultCharset off
}
At this point, your config file will look something like this:
Click on “Update Config” to save the settings.
Finally, we need to restart the OpenLiteSpeed service for the changes to take effect. Open the server page in your RunCloud dashboard and look for the “Services” option in the side menu. On that page, click on the “…” button next to the OpenLiteSpeed server and click “Restart”.
Log Into Your Ghost Dashboard
After setting up the proxy config, you can visit your website. Go to https://example.com/ghost to configure the admin account. On this page, you need to enter some basic details such as the name of the site and the login details of the admin.
After setting up the admin account, you can log into the Ghost dashboard and start publishing.
After Action Report
Ghost CMS is an effective modern publishing platform powered by Node.js. RunCloud makes it easy to install and configure Ghost CMS. After following the steps mentioned in this article, you will be able to set up your own CMS and start publishing content.
After installation, you can continue learning more about Ghost-CLI commands and tutorials to customize your Ghost blog.
If you’re tired of managing your own servers – check out RunCloud, a simple yet powerful control panel for cloud servers. RunCloud is built for developers that want to focus on shipping great work, not on managing their infrastructure. Discover painless server configuration and say goodbye to spending hours figuring it out – get started with RunCloud today to get up and running in minutes.