Ghost Configuration Tutorial

By default Ghost uses sqlite3 database. Still, if you would like to have your Ghost Blog installed and configured with MySQL database you can reconfigure the default settings in the config.js file following this guide.

Further reading:

Basic Features of the Ghost CMS

Ghost Backup and Restore Tutorial

Ghost Installation Tutorial

Ghost Management Tutorial

Ghost advanced script integration

How to migrate your website from WordPress to Ghost


How to Configure Ghost with MySQL


Login your server via SSH and navigate to your Ghost root directory. If you have followed our Ghost and Node installation guide your Ghost directory should be under /var/www/ghost.

Open config.js file using your favorite text editor and locate the Production environment settings which should be somewhere around line 43.

You will need to replace the following lines:

database: {
client: 'sqlite3',
connection: {
filename: path.join(__dirname, '/content/data/ghost2.db')
},

with your MySQL configuration using the following syntax:

database: {
client: 'mysql',
connection: {
host: 'localhost',
user: 'database-user',
password: 'database-user-password',
database: 'database-name',
charset: 'utf8'


Remember to replace database host, database-user, database-user-password and database-name with your actual settings. After that, you can continue with the Ghost Installation process.

Further reading:

Basic Features of the Ghost CMS

Ghost Backup and Restore Tutorial

Ghost Installation Tutorial

Ghost Management Tutorial

Ghost advanced script integration

How to migrate your website from WordPress to Ghost


Configure Apache proxy for Ghost on cPanel


If you have installed Ghost via Softaculous in the past, most likely your Ghost URL will look like this: https://blog.example.com:62227. The numbers after your domain name represent the Node port which services all requests to your Ghost blog. As Node is a standalone service, it requires a dedicated port different than the standard port 80 used by the Web Server.

Still, this might be very inconvenient for your visitors, and you might want to have your Ghost blog accessible via the standard port 80. To achieve this, you will need to perform a few easy steps on your server to configure the Apache proxy to redirect all requests to your custom Ghost blog installation port.

Further reading:

Basic Features of the Ghost CMS

Ghost Backup and Restore Tutorial

Ghost Installation Tutorial

Ghost Management Tutorial

Ghost advanced script integration

How to migrate your website from WordPress to Ghost


We can help

In case you are hosting your Ghost blog on our Ghost Hosting Package, please contact our support team, and we will set this for you in just a few minutes. If you are managing your server on your own, please follow the steps below.


To have your Ghost blog accessed without a port number in the URL, you need to:

Step 1: Create a userdata Directory
Step 2: Create a Proxy Config File
Step 3: Include the Config File in httpd.conf


Create a userdata Directory


First, you will need to create a folder under the "userdata" directory of your Apache web server. That can be done by executing:

mkdir -p /usr/local/apache/conf/userdata/std/2/USERNAME/DOMAIN/

Please replace "USERNAME" with your actual cPanel username and "USERNAME" with your actual domain or subdomain under which Ghost is installed.

Create a Proxy Config File


When the needed folders are created, navigate to your domain userdata directory and create a text file called ghost.conf. The content of the ghost.conf file should be:

ProxyPass / http://127.0.0.1: 62227/
ProxyPassReverse / http://127.0.0.1: 62227/

Please replace the port number 62227 with your actual Ghost port number provided to you during the installation process. When you are ready, save the file and exit the text editor program.

Include the Config File in httpd.conf


Next, you will need to edit your Apache httpd.conf. The exact path to the file is:

/etc/httpd/conf/httpd.conf

You can open the httpd.conf via your favorite text editor and you should search for your domain or subdomain vhost which should look like:

<VirtualHost 192.168.1.30:80>
ServerName blog.example.com
ServerAlias www.blog.example.com
.........
# To customize this VirtualHost use an include file at the following location
# Include "/usr/local/apache/conf/userdata/std/2/example/blog.example.com/*.conf"
</VirtualHost>


Here you should uncomment the last line which includes all .conf files from the directory you have just created. You can do this by removing the '#' sign at the beginning of the line. When you are done, save the file and exit the text editor program.

Now you should restart your Apache web service by executing:

/etc/init.d/httpd restart


After the Apache restart, all requests should be automatically handled by the Apache and redirected internally to the Node custom port. Now you can conveniently access your Ghost blog directly via your URL without the need to include the port number.

If you experienced any difficulties during the process, please contact our support team, and we will configure your Ghost blog for you.

 

Further reading:

Basic Features of the Ghost CMS

Ghost Backup and Restore Tutorial

Ghost Installation Tutorial

Ghost Management Tutorial

Ghost advanced script integration

How to migrate your website from WordPress to Ghost

 

How to configure your Ghost blog URL


In this tutorial we will show you how to configure your Ghost blog URL and set your domain name. If you have followed our Ghost Installation tutorial your Ghost instance should be located under: /var/www/ghost/. In case you have manually installed Ghost, please enter your Ghost directory and open the config.js file with your favorite text editor.

Locate the Production configuration section which should start around the 43th line of the config.js file with ### Production tag and change the following line:

url: 'http://my-ghost-blog.com',

Replace my-ghost-blog.com with your actual domain name or IP address depending on how you would like to access your Ghost blog.

When you have set your domain name save your changes and exit the text editor. To apply the changes you will need to restart your Ghost. In case you have followed our one-click installation tutorial or you are using Forever you can restart the Ghost process by simply killing the current execution -- it will be automatically restarted by Forever.

To view the process simply use the following command:

[root@ghost ghost]# ps auxf | grep ghost

This will give you the process running Ghost:

root 4200 0.3 7.6 1008668 78240 ? Sl 13:00 0:06 \_ /usr/local/bin/node /var/www/ghost/index.js

The process ID is the first number after the process user -- in this example the process ID is 4200. To stop the process use the process ID with the following command:

[root@ghost ghost]# kill -9 4200

Remember to change the process ID with your actual process ID. Forever should automatically restart your Ghost process.

 

Further reading:

Basic Features of the Ghost CMS

Ghost Backup and Restore Tutorial

Ghost Installation Tutorial

Ghost Management Tutorial

Ghost advanced script integration

How to migrate your website from WordPress to Ghost

 

How to change your Ghost Port


In this tutorial we will show you how to change your Ghost port. This can be useful if you would like to run your Ghost blog on the standard HTTP port 80 or if you would like to configure it on a different port and leave your main web service handle the request on port 80.

If you have followed our "How to install Ghost with auto-install script" your instance of Ghost should be located under:

/var/www/ghost/

In case you have manually installed Ghost, please enter your Ghost directory and open the config.js file with your favorite text editor.

Locate the Production configuration section which should start around the 43th line of the config.js file with ### Production tag and change this line:

// Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
port: '80'

Please change the number in the quotes with the desired port number for your Ghost instance. When you are ready save your changes and exit the text editor. To apply the changes you will need to restart your Ghost. In case you have followed our installation tutorial or you are using Forever you can restart the Ghost process by simply killing the current execution -- it will be automatically restarted by Forever.

To view the process simply use the following command:

[root@ghost ghost]# ps auxf | grep ghost
This will give you the process running Ghost:
root 4200 0.3 7.6 1008668 78240 ? Sl 13:00 0:06 \_ /usr/local/bin/node /var/www/ghost/index.js

The process ID is the first number after the process user -- in this example the process ID is 4200. To stop the process use the process ID with the following command:

[root@ghost ghost]# kill -9 4200

Note

Remember to change the process ID with your actual process ID. Forever should automatically restart your Ghost process. In case you do not use Forever you will need to manually restart your Ghost Node.js instance.

With all of this completed, you now know how to change the port of your Ghost Installation.

 

Further reading:

Basic Features of the Ghost CMS

Ghost Backup and Restore Tutorial

Ghost Installation Tutorial

Ghost Management Tutorial

Ghost advanced script integration

How to migrate your website from WordPress to Ghost

  • 2 Users Found This Useful
Was this answer helpful?

Related Articles

Basic Features of the Ghost CMS

Todhost web hosting supports Ghost installation. You can easily setup your website with Ghost...

How to migrate your website from WordPress to Ghost

The Ghost project is led by John O'Nolan and Hannah Wolfe, both of whom have been involved with...

Ghost Installation Tutorial

In this tutorial, we look at the various means to install the Ghost CMS. The options are to...

Ghost Management Tutorial

How to use the Ghost Publishing Platform   In order to make it easier for users to deploy and...

Ghost Backup and Restore Tutorial

We shall in this tutorial cover the steps you need to take to bkkcup your Ghost website and also...

Powered by WHMCompleteSolution