install node.js
yum install -y gcc-c++ make
yum install -y nodejs
download and deploy Ghost
# download
curl -L https://ghost.org/zip/ghost-latest.zip -o ghost.zip
# move to folder
mkidir /var/www
yum install -y unzip
unzip -uo ghost.zip -d /var/www/ghost
# install
cd /var/www/ghost
########################
# problem installing #
npm install --production
Ok.... It is the small RAM problem again. SOLUTION:
free
dd if=/dev/zero of=/var/swap.img bs=1024k count=1000
mkswap /var/swap.img
swapon /var/swap.img
free
And then, install again:
# in case you've installed and failed
npm cache clean
rm -rf /var/www/ghost/node_modules
# install
npm install --production
Starting Ghost
# firewall setting
firewall-cmd --permanent --add-port=2368/tcp
firewall-cmd --reload
# configure
vim config.js
# and change 'host' to '0.0.0.0'
# change 'url' to 'your-domain/blog'
# start
npm start --production
Deploy with Nginx and pm2(run forever)
install nginx first
yum install nginx -y
# enable and start nginx
systemctl enable nginx.service
systemctl start nginx.service
configure to listen port 80. Edit file /etc/nginx/conf.d/your-domain-name.conf
:
server {
listen 80;
server_name your-domain-name.com;
location ^~ /blog {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:2368;
}
}
restart nginx and open port 80 in firewall:
# firewall setting
firewall-cmd --permanent --add-service=http
# if you don't need testing
# firewall-cmd --permanent --remove-port=2368/tcp
firewall-cmd --reload
# restart
systemctl restart nginx.service
run forever
# install pm2
npm install pm2 -g
# run
cd /var/www/ghost
NODE_ENV=production pm2 start index.js --name "Ghost"
# stop or status
pm2 stop Ghost
pm2 restart Ghost
pm2 reload Ghost
pm2 show Ghost
DNS settings on GOdaddy
set 'A' record:
ip = server_ip
name = @
Ghost migrating older posts
The labs
supports export and import, but only for text and settings.
Your images in posts are located in <ghost-root>/content/images/YYYY/MM/
.
Extra functions
Highlighting code blocks
First, download prism.js from the website (select your favourate languages =-=).
Place the files in the proper assets folders in your theme - content/themes/<theme-name>/assets/js/prism.js
and content/thems/<theme-name>/assets/css/prism.css
Open content/themes/<theme-name>/default.hbs
file and add <link>
tag in the head for the style.
{{! Styles'n'Scripts }}
...
<link rel="stylesheet" type="text/css" href="{{asset "css/prism.css"}}" />
...
and a <script>
tag before the closing <body>
tag
...
<script type="text/javascript" src="{{asset "js/prism.js"}}"></script>
</body>
Then, you just need to restart you Ghost app.
LaTeX support
Use MathJax (CDN) .
Add a <script>
tag before the closing
...
<script type="text/javascript" src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</body>
Then, you just need to restart you Ghost app.
$$ I = I_0 \cdot \text{e}^{-l/x} $$