参考:腾讯云手动实验https://cloud.tencent.com/developer/labs/lab/10281
Ghost 是一款非常出色的开源博客平台,界面简洁,专注写作。CentOS 7 上安装 Ghost ,包括安装 Nodejs 环境以及配置 Nginx 对 Ghost 的代理请求等步骤。
安装Node.js及相关包
限制使用node.js版本^8.16.0 || ^10.13.0 || ^12.10.0
代码语言:javascript复制[root@localhost ~]# yum -y update
[root@localhost ~]# yum groupinstall -y "Development Tools"
--setopt=group_package_types=mandatory,default,optional
[root@localhost ~]# wget https://npm.taobao.org/mirrors/node/v12.16.2/node-v12.16.2-linux-x64.tar.xz
[root@localhost ~]# tar xf node-v12.16.2-linux-x64.tar.xz
[root@localhost ~]# mv node-v12.16.2-linux-x64 /usr/local/nodejs
[root@localhost ~]# vim /etc/profile
# 末尾添加
export PATH=$PATH:/usr/local/nodejs/bin
[root@localhost ~]# source /etc/profile
[root@localhost ~]# node -v
v12.16.2
[root@localhost ~]# npm -v
6.14.4
[root@localhost ~]# npm config set registry https://registry.npm.taobao.org
[root@localhost ~]# npm i -g cnpm
安装成功后通过运行node -v及npm -v 出现版本号即可表示安装成功。
因为国内网络的关系,也同时安装了 cnpm 模块,后续将使用该命令代替 npm 命令。
安装Ghost Client
代码语言:javascript复制[root@localhost ~]# cnpm i -g ghost-cli
...
[ghost-cli@1.13.1] link /usr/bin/ghost@ -> /usr/lib/node_modules/ghost-cli/bin/ghost
[root@localhost ~]# ghost -v
Ghost-CLI version: 1.13.1
一般而言,安装成功后通过运行 ghost -v,出现版本号即可表示安装成功。但因为国内的网络问题,安装后请检查下终端的 log,如果有出现任意红色报错信息,则证明只有部分安装成功,需要重新执行命令安装。
安装Ghost 添加Ghost程序用户,并创建目录
代码语言:javascript复制[root@localhost ~]# adduser ghost
[root@localhost ~]# mkdir -p /var/www/ghost
[root@localhost ~]# chown ghost /var/www/ghost/
安装Ghost
代码语言:javascript复制[root@localhost ~]# su ghost
[ghost@localhost root]$ cd /var/www/ghost/
[ghost@localhost ghost]$ ghost install local --db=sqlite3
# 这里需要相当长的时间
✔ Checking system Node.js version
✔ Checking current folder permissions
✔ Checking memory availability
✔ Checking for latest Ghost version
✔ Setting up install directory
✔ Downloading and installing Ghost v3.14.0
✔ Finishing install process
✔ Configuring Ghost
✔ Setting up instance
✔ Starting Ghost
Ghost uses direct mail by default. To set up an alternative email method read our docs at https://ghost.org/docs/concepts/config/#mail
------------------------------------------------------------------------------
Ghost was installed successfully! To complete setup of your publication, visit:
http://localhost:2368/ghost/
启动Ghost
代码语言:javascript复制[ghost@localhost ghost]$ ghost start
Ghost is already running! For more information, run:
ghost ls
[ghost@localhost ghost]$ ghost ls
┌─────────────┬────────────────┬─────────┬───────────────────────┬────────────────────────┬──────┬─────────────────┐
│ Name │ Location │ Version │ Status │ URL │ Port │ Process Manager │
├─────────────┼────────────────┼─────────┼───────────────────────┼────────────────────────┼──────┼─────────────────┤
│ ghost-local │ /var/www/ghost │ 3.40.5 │ running (development) │ http://localhost:2368/ │ 2368 │ local │
└─────────────┴────────────────┴─────────┴───────────────────────┴────────────────────────┴──────┴─────────────────┘
安装nginx 配置yum源
代码语言:javascript复制[ghost@localhost ghost]$ exit
exit
[root@localhost ~]# rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
安装nginx
代码语言:javascript复制[root@localhost ~]# yum -y install nginx
启动nginx
代码语言:javascript复制[root@localhost ~]# systemctl start nginx
配置反向代理 修改nginx配置文件
代码语言:javascript复制[root@localhost ~]# vim /etc/nginx/conf.d/default.conf
location / {
proxy_pass http://127.0.0.1:2368;
proxy_redirect default;
root /usr/share/nginx/html;
index index.html index.htm;
}
重启nginx
代码语言:javascript复制[root@localhost ~]# nginx -s stop
[root@localhost ~]# nginx
验证
访问http://192.168.1.10/ghost/
http://192.168.1.10
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/101873.html原文链接:https://javaforall.cn