Install nodejs(Required)
- download nodejs v0.10.40, see ghost supported node version
- add nodejs to PATH
tar zxvf node-v0.10.40-linux-x86.tar.gz
ln -s /{node_install_path}/bin/node /usr/local/bin/node
ln -s /{node_install_path}/bin/npm /usr/local/bin/npm
- check version,
node -v
&npm -v
Install ghost(Required)
- download ghost-latest.zip
unzip -uo ghost-latest.zip -d ghost
- execute cmd
npm install --production
in ghost folder. - modify
config.js
, remove the unused options
var path = require('path'), config;
config = {
production: {
url: 'http://www.mydomain.com',
mail: {},
database: {
client: 'sqlite3',
connection: {
filename: path.join(__dirname, '/content/data/ghost.db')
},
debug: false
},
server: {
host: '127.0.0.1',
port: '2368'
}
}
};
module.exports = config;
Run ghost
- execute cmd
npm start --production
in ghost folder - now, you can access http://127.0.0.1:2368 & http://127.0.0.1:2368/ghost
Nginx & Domain(Optional)
- install nginx :
yum install nginx
- modify
/etc/nginx/conf.d/default.conf
, don't forget backup the file :)
server {
listen 80;
server_name www.mydomain.com;
charset utf-8;
access_log /var/log/nginx/log/host.access.log main;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:2368;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
- restart nginx
service nginx restart
- don't forget to setup the domain on DNS provider.
Forever(Recommend)
- execute cmd
npm install forever -g
- create shell script
ghost.sh
NODE_ENV=production forever start index.js
- create shell script
ghost-stop.sh
forever stop index.js
Usage
-
sh ghost.sh
for startup -
sh ghost-stop.sh
for shutdown
Enjoy it :)