Ghost 是一款使用 Node.js 开发的博客系统,相对于使用 PHP 开发的 WordPress 更轻巧友好,所以本站已经从 WordPress 切换至 Ghost,本文介绍在 Debian 8.x 和 Ubuntu 16.04 下搭建 Ghost 的教程

本文所有操作均在 root 用户下进行,请自行切换

首先,更新系统

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

由于系统自带的 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 用户并修改权限

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 按照实际情况,修改 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', //修改为你博客的域名,如需要启动 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'
}
},

如果需要后台发送邮件给用户,您可以配置 mail 参数,例如:

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

Ghost 用的是 Nodemailer,如果您需要其他服务商的 service 名字,可以在官网文档里查看。

6、安装并启动 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

可以在本机上打开 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 保持后台运行

PM2 是一款很流行的 Node.js 进程管理器,可以做到开机启动和重新关闭等操作

首先我们通过 npm 安装 PM2

cd /var/www/ghost
npm install pm2 -g

配置当前环境,并设置开启启动,然后保存

NODE_ENV=production pm2 start index.js --name ghost
pm2 startup
pm2 save

后续可能需要用到的命令有

启动 Ghost

pm2 start ghost

停止 Ghost

pm2 stop ghost

重启 Ghost

一般用于修改了主题文件或进程隔屁的情况

pm2 restart ghost

好了,大功告成,打开浏览器访问 http://example.com/ghost/ 注册的第一个账号就是全站管理员,接着就可以开始 Ghost 的博客之旅了

扩展阅读

观赏鱼品种大全

鹿角苔需要怎么养

水族有趣见闻

国内最有意思的水族观赏鱼论坛

Debian 8.x / Ubuntu 16.04.x 搭建 Ghost 教程的更多相关文章

  1. Ubuntu 16.04安装Matlab 2016b教程

    由于代码需要依赖Linux环境,只好尝试着装MATLAB,然而各种问题接踵而至,开始了由MATLAB引发的三天Linux探寻之旅-- 下载Matlab 2016b for Linux https:// ...

  2. Windows + Ubuntu 16.04 双系统安装详细教程

    Windows + Ubuntu 16.04 双系统安装详细教程 2018年01月28日 16:43:19 flyyufenfei 阅读数:165619   发现了一篇好教程,果断转载了,以后用得着时 ...

  3. Ubuntu 16.04上搭建CDH5.16.1集群

    本文参考自:<Ubuntu16.04上搭建CDH5.14集群> 1.准备三台(CDH默认配置为三台)安装Ubuntu 16.04.4 LTS系统的服务器,假设ip地址分布为 192.168 ...

  4. Ubuntu 16.04 LTS 搭建ftp服务器

    其实我之前搭建好了,但是最近我上来看好像跟没搭建一样呢,于是我从新搭建一遍? 我的ubuntu版本: cat /etc/issue Ubuntu 16.04 LTS \n \l 1.安装vsftpd( ...

  5. Ubuntu 16.04 apt-get搭建LAMP环境

    本文重点介绍在Ubuntu中使用apt-get安装LAMP(Ubuntu 16.04,Apache2.4.18,mysql5.7.12,php7.0.4)环境,所以不再介绍如何安装Ubuntu. 安装 ...

  6. Ubuntu 16.04下搭建kubernetes集群环境

    简介 目前Kubernetes为Ubuntu提供的kube-up脚本,不支持15.10以及16.04这两个使用systemd作为init系统的版本. 这里详细介绍一下如何以非Docker方式在Ubun ...

  7. Vmvare + Ubuntu 16.04环境搭建 + 相关软件安装配置笔记【深度学习】

    前言 由于学习与工作的需要,加上之前配置好的vmmachines都损坏了,我就重新弄一个ubuntu虚拟机,配置一下环境,给自己留个记录 1.文件 2.配置过程 1.在Vmware中新建虚拟机,自定义 ...

  8. Pycharm 4.5.4 for ubuntu 16.04 下载与安装教程

    首先,我们需要有一台已经安装好 ubuntu 16.04 的操作系统,并且配置好java环境: 方法1: 默认安装 apt-get install default-jdk -y # 安装官网最新的ja ...

  9. 虚拟机安装Ubuntu 16.04系统实操教程 详尽步骤 vmware ESXi亲测通过

    1 Ubuntu 16.04系统安装要求 Ubuntu 16.04 LTS下载最新版本的Ubuntu,适用于台式机和笔记本电脑. LTS代表长期支持,这意味着有五年免费安全和维护更新的保证. Ubun ...

随机推荐

  1. Python 解决命令行删除、退格乱码问题

    安装了python 在命令行界面无法进行删除.退格 1 安装readline模块 两种方式:yum install -y readline-devel  readline 或者 下载文件https:/ ...

  2. MMU二级页表

    https://blog.csdn.net/forDreamYue/article/details/78887035

  3. Juniper BGP配置

    网络拓扑如下: XRV1配置 =========================================================== root@XRV1# run show confi ...

  4. 内网ssh穿透

    公司服务器没有公网IP,只有内网IP,利用自己的阿里云服务器(有公网ip)做ssh内网穿透,使得外网可访问.方法如下: 环境: 公司服务器和阿里云服务器均为 Ubuntu 操作系统, 需要修改阿里云服 ...

  5. wpf 给listview的数据源转换为集合

    目的是点击某个按钮把一条数据从 itemssource中移除 private void delete_Click_1(object sender, RoutedEventArgs e) { DtsIn ...

  6. dsPIC30F 细节点问题不定期更新ing

    知识点1 TRISD: I/O 引脚 方向控制 寄存器 (1--input, 0--Output)LATD:  I/O 引脚 输出锁存器PORTD: 是双向I/O 端口 备注:LATD = 0x000 ...

  7. 14. Redis配置统计字典

    14. Redis配置统计字典14.1 info系统状态说明14.1.1 命令说明14.1.2 详细说明14.2 standalone配置说明和分析14.2.1 总体配置14.2.2 最大内存及策略1 ...

  8. optional的使用

    :first-child { margin-top: 0px; } .markdown-preview:not([data-use-github-style]) h1, .markdown-previ ...

  9. MathExam Lv2

    一个大气又可爱的算术题----211606360 丁培晖 211606343 杨宇潇 一.预估与实际 PSP2.1 Personal Software Process Stages 预估耗时(分钟) ...

  10. Codeforces Round #436 (Div. 2)D. Make a Permutation! 模拟

    D. Make a Permutation! time limit per test: 2 seconds memory limit per test: 256 megabytes input: st ...