This tutorial will guide you through installing the latest version of Ghost on a fresh CentOS VPS.
Quick Note: While this tutorial is here to assist with installing Ghost on CentOS, we cannot provide development or configuration support. If you have any questions regarding Ghost, we recommend the Ghost forums.
Tutorial Assumptions
- You have a fresh CentOS VPS with root access
- You have a domain name with DNS hosting (optional)
1. Install Common Packages
First, login to SSH on your CentOS VPS and install the following packages via:
[bash] sudo yum install unzip curl wget glibc-* screen @Development Toolssudo yum update
[/bash]
2. Install NodeJS / NPM for Ghost
Next, install NodeJS and NPM, this is what Ghost will run on:
[bash] sudo rpm -Uvhsudo yum install npm
[/bash]
Verify that your Node and NPM installation is working correctly by issuing:
[bash] node -v && npm -v[/bash]
If Node and NPM were installed succesfully, you should see the respective version numbers returned:
[bash] v0.10.181.3.6
[/bash]
3. Install Ghost on CentOS
Now we can install Ghost. In this instance, we have retrieved a direct link for download, however please ensure that you are always fetching the latest version. The latest version can be obtained via your Ghost account.
[bash] mkdir -p /var/www/ghost && cd /var/www/ghostsudo curl -O
sudo unzip ghost-*.zip
sudo rm -rf ghost-*.zip
mv config.example.js config.js
sed -i ‘s/2368/80/g’ config.js && sed -i ‘s/127.0.0.1/0.0.0.0/g’ config.js
sudo npm install –production
[/bash]
Ghost will be configured to run on port 80. You can change the way Ghost is configured by modifying the config.js file.
4. Start / Run Ghost in the Background
Next we can launch Ghost in the background. To do this, we’ll be using GNU/Screen, as seen below:
[bash] sudo screen -S Ghost -d -m npm start –production[/bash]
This will start a Ghost session in the background; you can exit the session by hitting CTRL +D.
5. Get Started with Ghost
You should now be able to see your Ghost instance running from your VPS’ IP address. To get started, simply navigate to:
Where x.x.x.x is your public IP address.
You will be prompted to setup an administrator account so you can start blogging straight away.
6. FAQ
How do I use a custom domain with Ghost?
To use a custom domain with Ghost, e.g. mydomainname.com, simply modify the following command by replacing ‘mydomainname.com’ with your domain and run it via SSH:
[bash] sed -i ‘s/my-ghost-blog.com/mydomainname.com/g’ /var/www/ghost/config.js[/bash]
Ensure that you replace mydomainname.com with your own domain name and you have setup A records to point to your VPS’ IP address.
How do I ensure Ghost starts on boot / startup?
We’ve created a CentOS Ghost upstart script that can achieve this for you.
Simply create a file in your /etc/init directory called ghost.conf with the following contents:
author "fastdot.com"
usage "This script will execute at runtime. No need for manual invoke!"
start on runlevel [2345] stop on runlevel [016]
script
cd /var/www/ghost
/usr/bin/npm start –production > /var/ghost-upstart.log
end script
[/bash]
Next time you reboot, Ghost will be automatically started in production mode.
How do I setup mail with Ghost? (Fixing Ghost is currently unable to send e-mail)
You can setup Ghost to work with a number of different ESP’s. We’ll be using Gmail in this scenario.
Note: it’s recommended that you setup an alternative Gmail address to send transaction emails.
First, open up /var/www/ghost/config.js and navigate to the production: {} stanza:
[bash] // ### Production// When running Ghost in the wild, use the production environment
// Configure your URL and mail settings here
production: {
[…] [/bash]
In here, you will see a mail: {} stanza, which resembles:
[bash] // ### Production// When running Ghost in the wild, use the production environment
// Configure your URL and mail settings here
production: {
url: ‘http://my-ghost-blog.com’,
mail: {},
[…] [/bash]
Remove the mail: {} stanza, and replace it with the following lines (ensuring that you keep up the trailing comma at the end)
Enter your Gmail address and password in the respective user and pass fields.
transport: ‘SMTP’,
options: {
auth: {
user: ‘youremail@gmail.com’,
pass: ‘yourpassword’
}
}
},
[/bash]