新聞中心
本文所有操作均在 root 用戶下進(jìn)行,請(qǐng)自行切換

成都創(chuàng)新互聯(lián)主要從事做網(wǎng)站、成都做網(wǎng)站、網(wǎng)頁(yè)設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)尼木,十載網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):18982081108
首先,更新系統(tǒng)
apt-get update && apt-get upgrade
如果您用的 Debian 8.x 開啟了 backports 也可以更新下
apt-get -t jessie-backports update && apt-get -t jessie-backports upgrade
1、安裝 Node.js 6.x LTS
由于系統(tǒng)自帶的 Node.js 較老,這里我們采用 NodeSource 編譯的 Node.js 源
ubuntu 下
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - sudo apt-get install nodejs
Debian 下
curl -sL https://deb.nodesource.com/setup_6.x | bash - apt-get install nodejs
2、安裝 Nginx
Ubuntu 下可以用 PPA
Debian 下可以用 Dotdeb
然后安裝 Nginx 以及一些必要的軟件
apt-get install nginx unzip wget curl sudo sqlite3
3、下載 Ghost
這里我們演示把 Ghost 下載并解壓在 /var/www/ghost 目錄
cd /var/www/ && wget https://ghost.org/zip/ghost-latest.zip && unzip ghost-latest.zip -d ghost && rm -rf ghost-latest.zip
4、添加 ghost 用戶并修改權(quán)限
useradd ghost
chown -R ghost:ghost /var/www/ghost
5、修改 config.js
cd /var/www/ghost cp -r config.example.js config.js
接著就可以修改 config.js 按照實(shí)際情況,修改 config 段,舉例如下
config = {
// ### Production // When running Ghost in the wild, use the production environment. // Configure your URL and mail settings here production: { url: 'http://example.com', //修改為你博客的域名,如需要啟動(dòng) 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' } },
如果需要后臺(tái)發(fā)送郵件給用戶,您可以配置 mail 參數(shù),例如:
mail: { transport: 'SMTP', options: { service: 'Mailgun', auth: { user: '', // mailgun username pass: '' // mailgun password } } },
Ghost 用的是 Nodemailer,如果您需要其他服務(wù)商的 service 名字,可以在官網(wǎng)文檔里查看。
6、安裝并啟動(dòng) Ghost
cd /var/www/ghost
npm install --production npm start --production
如果在 Ubuntu 16.04 下提示
Error: Cannot find module '/var/www/ghost/node_modules/sqlite3/lib/binding/node-v48-linux-x64/node_sqlite3.node'
則需要安裝 nodejs 的 sqlite3
npm install sqlite3 --save
可以在本機(jī)上打開 http://127.0.0.1:2368/ 查看在線版本
7、配置 Nginx
按 ctrl + c 停止 Ghost ,然后我們可以修改 Nginx 配置文件,舉例如下
server { listen 80; 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; } }
檢查并重新加載 nginx
nginx -t
nginx -s reload
8、安裝 PM2 使 Ghost 保持后臺(tái)運(yùn)行
PM2 是一款很流行的 Node.js 進(jìn)程管理器,可以做到開機(jī)啟動(dòng)和重新關(guān)閉等操作
首先我們通過 npm 安裝 PM2
cd /var/www/ghost npm install pm2 -g
配置當(dāng)前環(huán)境,并設(shè)置開啟啟動(dòng),然后保存
NODE_ENV=production pm2 start index.js --name ghost pm2 startup pm2 save
后續(xù)可能需要用到的命令有
啟動(dòng) Ghost
pm2 start ghost
停止 Ghost
pm2 stop ghost
重啟 Ghost
一般用于修改了主題文件或進(jìn)程隔屁的情況
pm2 restart ghost 網(wǎng)站欄目:Debian8.x/Ubuntu16.04.x搭建Ghost博客教程
URL網(wǎng)址:http://fisionsoft.com.cn/article/djsecpe.html


咨詢
建站咨詢
