Ghost is free and Open source blogging platform, it is written on javascript . It is very popular among many bloggers now a days. The Ghost is maintained by Ghost Foundation.
Do you want to know more about Ghost blogging platform and its history ? You can read about ghost blogging platform on Wikipedia.
Know more about the Ghost
1. The Ghost blogging platform written on Javascript.
2. By default database is sqlite whereas you can also use server/client database (RDBMS) like MySQL, Mariadb , postgres etc.
3. Default port number 2368 is used by the ghost. We can change the port number. (We can configure proxy pass in Apache / Nginx web server to access the ghost on http port)
4. We can easily configure Mail setting with credentials obtained from MailGun , AWS SES , Gmail etc.
5. The forgotten reset password will be sent to email id mentioned for the user. Hence, configure Mail settings. (In self hosted Ghost, you can reset it from database)
Note : Ghost requires Node.js 0.10.x (not 0.12.x). Ghost foundation recommends Node.js 0.10.36 & npm 2.5.0. (At the time of writing this post)
Our Server Description
Operating System : Ubuntu 14.04 LTS
Arch : x86_64
Database : sqlite
IP Address : 192.168.122.185
Step by step : Install Ghost blogging platform on Ubuntu
Follow the given below step by step tutorial to install ghost blogging platform on Ubuntu.
Step 1. Setup the Nodesource repository.
Use the below given command to setup the Nodesource repository.
curl -sL https://deb.nodesource.com/setup | sudo bash -
Step 2. Install nodejs
Because the Ghost is based upon javascript, we are now installing the nodejs package with apt-get command.
sudo apt-get install -y nodejs
Step 3. Install build tools
We require build tools to compile and install native addons from npm, hence use below given for this.
apt-get install -y build-essential
Step 4. Download Ghost package
Now download the ghost with below given command.
curl -L https://ghost.org/zip/ghost-latest.zip -o ghost.zip
Create directory ghost
We are creating the ghost directory inside /opt where we will decompress the source code.
As per your choice, you can place the ghost directory wherever you want. We recommend you to generally use /srv , /usr/local , /opt or /var/www .
sudo mkdir -p /opt/ghost
Step 5. Install unzip package
For decompression, we need unzip package here. In case, your system already has unzip , you can skip this step.
You can read about zip and unzip in more details from here.
sudo apt-get install unzip
Step 6: Unzip ghost.zip
Unzip the downloaded ghost.zip to /opt/ghost directory
sudo unzip -uo ghost.zip -d /opt/ghost
Step 7: Change to ghost directory
Change to ghost directory , as per our this post it is in /opt/ghost
First become superuser and change to /opt/ghost directory.
sudo su - cd /opt/ghost
Step 8: Install ghost in production environment [nodejs]
Now install ghost in production environment.
npm install --production
Step 9: Configure config.js file
Now configure the config.js file for Production environment. Because this is fresh setup, copy the config.example.js to config.js . You will see this file in ghost directory where you extracted the ghost.zip file.
cp -p config.example.js config.js
config.js file has many configuration settings. We first set the domain name on which it will work.
Edit the config.js file
vi config.js
In config.js file , find the below given line.
production: { url: 'http://my-ghost-blog.com',
And replace http://my-ghost-blog.com with your domain name. Here, I am using my domain name https://sharadchhetri.com
production: { url: 'https://sharadchhetri.com',
We also prefer to change the 127.0.0.1 ip address in production setting with our server ip address.
Our system ip address is 192.168.122.185 , you can find your server ip address by using ifconfig
command .
Edit the 127.0.0.1 ip address with your server ip address
host: '127.0.0.1',
Because my server ip address is 192.168.122.185, I replaced with 127.0.0.1 . Get your server ip address and do the same.
host: '192.168.122.185',
Given below is reference of Production environment settings in config.js file. We have selected only production section, the config.js file has more contents inside.
Note: The ghost server runs on port number 2368 by defualt. If you want to change to other port , you can give new value at port:
. For understanding , have a look into below given our reference.
Given below is reference from our server –
production: { url: 'https://sharadchhetri.com', mail: {}, database: { client: 'sqlite3', connection: { filename: path.join(__dirname, '/content/data/ghost.db') }, debug: false }, server: { // Host to be passed to node's `net.Server#listen()` host: '192.168.122.185', // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT` port: '2368' } },
Step 10 : Start the ghost server
Once all settings are completed, start the ghost server with below given command. Switch to superuser before running ghost server.
sudo su - cd /opt/ghost npm start --production
Or To run the Ghost (node process) at background, even ssh session is this will keep running. Use below given command. (We recommend this)
sudo su - cd /opt/ghost nohup npm start --production > Ghost-Output.out 2> Ghost-Error.err < /dev/null &
To stop the ghost server , you have to press key CTRL + C
on terminal from your keyboard.
OR to stop ghost server , kill the node process.Just as given below
sudo pkill node
See ghost server in action, when we start the ghost server with npm command.
Note: This command is not running the node process in background.
root@ubuntu:/opt/ghost# npm start --production > ghost@0.6.4 start /opt/ghost > node index Migrations: Database initialisation required for version 003 Migrations: Creating tables... Migrations: Creating table: posts Migrations: Creating table: users Migrations: Creating table: roles Migrations: Creating table: roles_users Migrations: Creating table: permissions Migrations: Creating table: permissions_users Migrations: Creating table: permissions_roles Migrations: Creating table: permissions_apps Migrations: Creating table: settings Migrations: Creating table: tags Migrations: Creating table: posts_tags Migrations: Creating table: apps Migrations: Creating table: app_settings Migrations: Creating table: app_fields Migrations: Creating table: clients Migrations: Creating table: accesstokens Migrations: Creating table: refreshtokens Migrations: Populating fixtures Migrations: Populating permissions Migrations: Creating owner Migrations: Populating default settings Migrations: Complete Ghost is running... Your blog is now available on https://sharadchhetri.com Ctrl+C to shut down
Step 11 : Open the ghost on web browser
You can see your ghost on web page , open the web browser and on address field type http://
. Replace,
See given below screenshot reference from our system:
Create your ghost admin user
Now create ghost admin user. This will be done from web browser. You have to put /ghost
at the end of URL. See the below reference, do not forget to replace ip-address-of-ghost-server with actual ip address of your ghost server.
http://
You will get the setup page, fill up the form and set the password for admin user.
You can see below reference, which we have done on our ghost setup.
Once you clicked on submit button, within a few seconds or minute and you will directly login into shiny ghost dashboard.
Here, it looks like this.See the given below screenshot -
Step 12 : How to login into ghost admin dashboard
Once you logout, to login into ghost admin dashboard, you have to use suffix /ghost in URL.
http://ip-address-ghost-server:2368/ghost
See the given below example :