From the cPanel SOFTWARE section, click the Setup Node.js App icon.
Click the CREATE APPLICATION button. Complete the fields. In our example, we will be installing the application in /home/youraccount/myghostblog, and be serving it from http://krystaldemo.co.uk/blog, using Node.js version 10.
Installation of the Ghost blog software must be done from the command line. SSH into your account, and enter this command (replacing your cPanel username and Application root as required) This will enter you into a virtual shell environment setup for the Node.js version your application uses. Entering the pwd command should show that you are now in the application's root directory.
Next, install the ghost-cli, a command line interface for managing ghost installations.
$ npm install [email protected] -g /home/krystald/nodevenv/myghostblog/10/lib/bin/ghost -> /home/krystald/nodevenv/myghostblog/10/lib/lib/node_modules/ghost-cli/bin/ghost + [email protected] added 363 packages from 191 contributors in 27.297s
The ghost binary (which is actually the ghost-cli binary) is installed. We will need the your version of the path highlighted above in a while, so make a note of it.
Now, we must remove all files from the application root directory (/home/krystald/myghostblog) so it's empty again (otherwise ghost won't install in the next step). BE VERY CAREFUL to make sure you are in the correct directory - enter the pwd command again to make sure you are in the Application root directory before issuing the rm -rf * command
$ pwd /home/krystald/myghostblog $ rm -rf *
Now we are ready to install the ghost blog software itself. We don't want it to try and install nginx or MySQL, so we use the --no-setup option along with the ghost cli command we highlighted above.
$ /home/krystald/nodevenv/myghostblog/10/lib/bin/ghost install local --no-setup ✔ Checking system Node.js version ✔ Checking current folder permissions ✔ Checking memory availability ✔ Checking for latest Ghost version ✔ Setting up install directory ✔ Downloading and installing Ghost v2.31.1 ✔ Finishing install process
This process can take a minute or two, so please be patient. Once installed, there are a few things we need to do in order to get Ghost running. Passenger, the software which allows your application to be served via LiteSpeed, requires the public directory exist in the Application root, so run the following command:
$ mkdir public $ chmod 755 public
Your Application root should now contain the following file/directory structure
[myghostblog (10)] [[email protected]er myghostblog]$ ls -la total 8 drwxr-xr-x 5 krystald krystald 103 Oct 3 08:57 . drwx--x--x 24 krystald krystald 4096 Oct 3 08:53 .. drwxrwxr-x 8 krystald krystald 108 Oct 3 08:51 content lrwxrwxrwx 1 krystald krystald 42 Oct 3 08:53 current -> /home/krystald/myghostblog/versions/2.31.1 -rw-rw-r-- 1 krystald krystald 60 Oct 3 08:53 .ghost-cli drwxr-xr-x 2 krystald krystald 10 Oct 3 08:57 public drwxrwxr-x 3 krystald krystald 27 Oct 3 08:51 versions
Because ghost-cli installs the app into [Application root]/current, we need to create the default app.js file expected by Passenger and tell it where to find the Ghost application bootstrap file. Start Nano from the command line with: $ nano app.js once in nano, type the following as the first and only line const app = require('./current/index.js'); Then, save the file by pressing Ctrl-x then capital Y to confirm, and hit enter to confirm the filename. We must setup a MySQL database and MySQL user using the tools within cPanel. This is covered in our separate guide on creating MySQL Databases and Users - link opens in a new window.
The next step requires considerable editing, so you may want to edit the file locally using an editor of your choosing. Use your details for the paths as well as the MySQL database name, database user and password. Modify ./current/core/server/config/env/config.production.json as follows:
Once you have modified the above file and saved it, go back into the cPanel Node.js management screen, and restart the application using the Actions controls on the right hand side.
If all is well, you should now be able to browse to your website at the URL you set the application up on, in our case, http://krystaldemo.co.uk
It may take a few moments for the application to start, during which time you may see the following message.This is normal. After a few moments you should be able to refresh the page and see your blog.
To setup our blog, browse to http://krystaldemo.co.uk/blog/ghost/#/setup (your URL will differ, depending on the URL you setup for the Application) - here you can setup your own admin login:Once you have setup your admin area, to get back to the admin login in future, simply append ghost to the end of your blog URL e.g. http://krystaldemo.co.uk/blog/ghost