Debian 8.x/ubuntu 16.04.x Build Ghost Tutorial

Source: Internet
Author: User
Tags install node nodesource

Ghost is a blog system developed using node. JS, compared to the use of PHP developed WordPress more lightweight and friendly, so this site has been switched from WordPress to Ghost, this article introduced in the Debian 8.x and Ubuntu 16.04 under the building Ghost's Tutorial

All operations in this article are done under root user, please switch on your own

First, update the system

update && apt-get upgrade

If you use the Debian 8.x to open the Backports can also be updated under

update && apt-get -t jessie-backports upgrade
1. Install node. JS 6.x LTS

Since the system comes with node. js Older, here we use the Nodesource compiled node. JS Source

Under Ubuntu

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -sudo apt-get install nodejs

Under Debian

curl -sL https://deb.nodesource.com/setup_6.x | bash -apt-get install nodejs
2. Installing Nginx

Ubuntu can be used under the PPA

Dotdeb can be used under Debian

Then install the Nginx and some necessary software

apt-get install nginx unzip wget curl sudo sqlite3
3. Download Ghost

Here we demonstrate to download Ghost and unzip it in the/var/www/ghost directory

cd /var/www/ && wget https://ghost.org/zip/ghost-latest.zip && unzip ghost-latest.zip -d ghost && rm -rf ghost-latest.zip
4. Add Ghost Users and Modify permissions
useradd ghostchown -R ghost:ghost /var/www/ghost
5, modify the Config.js
cd /var/www/ghostcp -r config.example.js config.js

Then you can revise the config.js paragraph according to the actual situation, config for example as follows

config = {    // ### Production    // When running Ghost in the wild, use the production environment.    // Configure your URL and mail settings here    production: {        url: ‘http://example.com‘, //修改为你博客的域名,如需要启动 SSL 则改为 https mail: {}, database: { client: ‘sqlite3‘, connection: { filename: path.join(__dirname, ‘/content/data/ghost.db‘) }, debug: false }, server: { host: ‘127.0.0.1‘, port: ‘2368‘ } },

If you need to send mail to the user in the background, you can configure the mail parameters, for example:

mail: {      transport: ‘SMTP‘,      options: {          service: ‘Mailgun‘,          auth: {              user: ‘‘, // mailgun username pass: ‘‘ // mailgun password } } },

Ghost uses Nodemailer, if you need the service name of another service provider, you can check it in the official documents.

6. Install and start Ghost
install --productionnpm start --production

If you are prompted under Ubuntu 16.04

Error: Cannot find module ‘/var/www/ghost/node_modules/sqlite3/lib/binding/node-v48-linux-x64/node_sqlite3.node‘

You need to install the Nodejs sqlite3

install sqlite3 --save

You can open it on this computer to http://127.0.0.1:2368/ view the online version

7. Configure Nginx

Press ctrl + c stop Ghost, and then we can modify the Nginx configuration file, for example as follows

server {Listen80;Listen [::]:80;server_name example.com;Location/{Proxy_pass http://127.0.0.1:2368;Proxy_redirect default;Proxy_set_header Host$http _host;Proxy_set_header X-real-ip$remote _addr;Proxy_set_header x-forwarded-for$proxy _add_x_forwarded_for;Proxy_set_header x-forward-for$proxy _add_x_forwarded_for;Proxy_set_header X-forward-ip$remote _addr;proxy_set_header x-forwarded-proto  $scheme; client_max_body_size 10m; client_body_buffer_size 512k; proxy_connect_timeout 5; proxy_read_timeout 60; proxy_send_timeout 5; proxy_buffer_size 16k; proxy_buffers 4 64k; proxy_busy_buffers_size 128k; proxy_hide_header x-powered-by;}         

Check and Reload Nginx

-s reload
8. Install PM2 to keep Ghost running in the background

PM2 is a popular node. JS Process Manager that allows you to start up and shut down again

First we install PM2 via NPM

cd /var/www/ghostnpm install pm2 -g

Configure the current environment and set the startup to on, then save

start index.js --name ghostpm2 startuppm2 save

Subsequent commands that may need to be used are

Start Ghost
pm2 start ghost
Stop Ghost
pm2 stop ghost
Restart Ghost

Typically used to modify a theme file or process fart

pm2 restart ghost

All right, you're done. The http://example.com/ghost/ first account that opens the browser access registration is the full-site administrator, and then you can start Ghost's blog tour.

Extended Reading

Ornamental Fish Variety Daquan

How does a antler moss need to be raised

Aquarium Fun and informative

The most interesting aquarium ornamental fish forum in China

Debian 8.x/ubuntu 16.04.x Build Ghost Tutorial

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.