简介
Ghost 是一个基于 NodeJs 完全开源的,用于构建和运行现代出版物的强大平台,平台支持博客、杂志、新闻等发布。
它由前 WordPress UI 部门主管 John O’Nolan 和 WordPress 高级工程师 Hannah Wolfe 创立,
目的是为了给用户提供一种更加纯粹的内容写作与发布平台,使命是为世界各地的独立记者和作家创建最好的开源工具。
Ghost 成立于 2013 年 4 月,在 2013 年 9 月份 Ghost 正式向公众发布。
官网
https://ghost.org/
https://ghost.org/docs/install/local/#install-ghost
安装环境
CentOS-7
- Ghost
- Nginx
- Node.js
- Python
- MySQL
安装要求
- Intel x86 or compatible processor
- Minimum of 256 MB RAM
- Minimum of 150 MB hard drive space
- TCP/IP protocol support
- Compatible operantig systems:
- An x86 or x64 Linux operating system.
- A Windows operating system such as Windows Vista, Windows 7, Windows 8, Windows 10, Windows Server 2008 or Windows Server 2012.
- An OS X operating system.
安装 nginx
# 安装
yum install nginx -y
# 配置 nginx 开机启动
systemctl enable nginx
# 启动 nginx 服务
systemctl start nginx
# 查看 nginx 服务是否启动成功
ps -ef | grep nginx
安装 Node.js
# 更新系统
yum -y update
# 安装 EPEL
yum install epel-release -y
# 安装 Node.js 和 npm
yum install nodejs npm --enablerepo=epel
#
#
#
========================================================================================================================================
Package 架构 版本 源 大小
========================================================================================================================================
正在安装:
nodejs x86_64 1:6.17.1-1.el7 epel 4.7 M
npm x86_64 1:3.10.10-1.6.17.1.1.el7 epel 2.5 M
为依赖而安装:
libicu x86_64 50.2-4.el7_7 updates 6.9 M
libuv x86_64 1:1.34.0-1.el7 epel 144 k
事务概要
========================================================================================================================================
安装 2 软件包 (+2 依赖软件包)
总下载量:14 M
安装大小:51 M
#
#
#
# 安装 node.js 管理工具
npm install -g n
#
#
#
/usr/bin/n -> /usr/lib/node_modules/n/bin/n
/usr/lib
└── [email protected]
#
#
#
# 安装稳定版本的 node.js
# 运行 n 命令,选择已安装的 node.js 8.11.3 版本
n 8.11.3
installing : node-v8.11.3
mkdir : /usr/local/n/versions/node/8.11.3
fetch : https://nodejs.org/dist/v8.11.3/node-v8.11.3-linux-x64.tar.xz
installed : v8.11.3 (with npm 5.6.0)
Note: the node command changed location and the old location may be remembered in your current shell.
old : /usr/bin/node
new : /usr/local/bin/node
To reset the command location hash either start a new shell, or execute PATH="$PATH"
#
#
#
# 编辑环境配置文件
vim ~/.bash_profile
# 在文件末尾添加下列信息
exportN_PREFIX=/usr/local/bin/node
exportPATH=$N_PREFIX/bin:$PATH
# 执行以下命令使配置生效
source ~/.bash_profile
# 安装进程管理器,来控制 Node.js 应用程序。进程管理器可以保持应用程序一直处于运行状态
npm install pm2 -g
#
#
#
/usr/local/bin/pm2 -> /usr/local/lib/node_modules/pm2/bin/pm2
/usr/local/bin/pm2-dev -> /usr/local/lib/node_modules/pm2/bin/pm2-dev
/usr/local/bin/pm2-docker -> /usr/local/lib/node_modules/pm2/bin/pm2-docker
/usr/local/bin/pm2-runtime -> /usr/local/lib/node_modules/pm2/bin/pm2-runtime
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/pm2/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
+ [email protected]
added 199 packages in 75.388s
#
#
#
# 检查 Node.js 的版本
node -v
v8.11.3
npm -v
5.6.0
安装 Ghost
# 创建 Ghost 安装目录
mkdir -p /var/www/ghost
# 进入 Ghost 安装目录,下载最新版本的 Ghost 安装包
cd /var/www/ghost
wget https://ghost.org/zip/ghost-latest.zip
unzip ghost-latest.zip
# 安装 gcc 和 c++ 编译器
yum -y install gcc gcc-c++
# 使用 npm 安装 Ghost
npm install -production
#
#
#
npm WARN notice [SECURITY] express-brute has the following vulnerability: 1 high. Go here for more details: https://www.npmjs.com/advisories?search=express-brute&version=1.0.1 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
npm WARN deprecated [email protected]: All versions below 4.0.1 of Nodemailer are deprecated. See https://nodemailer.com/status/
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: This project is unmaintained
npm WARN notice [SECURITY] mime has the following vulnerability: 1 moderate. Go here for more details: https://www.npmjs.com/advisories?search=mime&version=1.2.11 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
npm WARN deprecated [email protected]: This project is unmaintained
npm WARN deprecated [email protected]: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated
> [email protected] install /var/www/ghost/node_modules/dtrace-provider
> node-gyp rebuild || node suppress-error.js
make: 进入目录“/var/www/ghost/node_modules/dtrace-provider/build”
TOUCH Release/obj.target/DTraceProviderStub.stamp
make: 离开目录“/var/www/ghost/node_modules/dtrace-provider/build”
> [email protected] install /var/www/ghost/node_modules/sqlite3
> node-pre-gyp install --fallback-to-build
node-pre-gyp WARN Using request for node-pre-gyp https download
[sqlite3] Success: "/var/www/ghost/node_modules/sqlite3/lib/binding/node-v57-linux-x64/node_sqlite3.node" is installed via remote
> [email protected] install /var/www/ghost/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install --runtime=napi) || (node-gyp rebuild && node install/dll-copy)
info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.9.1/libvips-8.9.1-linux-x64.tar.gz
#
#
#
# 运行 npm start 命令启动 Ghost,检查是否安装成功。
# 修改配置文件
vi /var/www/ghost/core/server/config/env/config.development.json
# 配置 config.development.json 文件中的 URL 为 Ghost 博客的域名
#
#
#
{
"url": "http://localhost:2368",
"database": {
"client": "sqlite3",
"connection": {
"filename": "content/data/ghost-dev.db"
},
"debug": false
},
"paths": {
"contentPath": "content/"
},
"privacy": {
"useRpcPing": false,
"useUpdateCheck": true
},
"useMinFiles": false,
"caching": {
"theme": {
"maxAge": 0
},
"admin": {
"maxAge": 0
}
}
}
#
#
#
# 安装 gcc 和 c++ 编译器
yum -y install gcc gcc-c++
# 使用 npm 安装 Ghost
npm install -production
# 运行 npm start 命令启动 Ghost,检查是否安装成功
cd /var/www/ghost/
npm start
配置 Nginx 作为 Ghost 的反向代理
# 新建 Ghost 博客的 Nginx 配置文件
vim /etc/nginx/conf.d/ghost.conf
# 将以下内容输入到 ghost.conf 中,把 server_name 改成 Ghost 实际的域名
upstream ghost {
server 127.0.0.1:2368;
}
server {
listen 80;
server_name myghostblog.com;
access_log /var/log/nginx/ghost.access.log;
error_log /var/log/nginx/ghost.error.log;
proxy_buffers 16 64k;
proxy_buffer_size 128k;
location / {
proxy_pass http://ghost;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_X_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
}
}
nginx -t
# 重启
systemctl restart nginx.service
启动 Ghost
cd /var/www/ghost/
npm start
配置防火墙
# 查看防火墙【服务】状态
systemctl status firewalld
# 查看防火墙【运行】状态
firewall-cmd --state
# 开启
service firewalld start
# 重启
service firewalld restart
# 关闭
service firewalld stop
# 查询端口是否开放
firewall-cmd --query-port=8080/tcp
# 开放80端口
firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --permanent --add-port=8080-8085/tcp
# 移除端口
firewall-cmd --permanent --remove-port=8080/tcp
# 查看防火墙的开放的端口
firewall-cmd --permanent --list-ports
# 重启防火墙(修改配置后要重启防火墙)
firewall-cmd --reload