运行环境:
1. Ubuntu16 X64
2. 宝塔5.4.0
安装 宝塔面板
wget -O install.sh http://download.bt.cn/install/install-ubuntu.sh && sudo bash install.sh
安装 Node.js
如果安装官方文档来加入安装Node.js源,因为不可描述的原因,你会发现安装得很慢。所以这儿我推荐大家直接在仓库源安装吧
# apt-get install -y nodejs #Ubuntu
# yum install -y nodejs #Centos
# curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash
然后刷新源安装Node.js:
apt-get update #Ubuntu
apt-get install -y nodejs #Ubuntu
yum update #Centos
yum install -y nodejs #Centos
这样Node.js环境安装好了。
替换国内npm环境
//打开配置文件
nano ~/.npmrc
//写入配置文件
registry =https://registry.npm.taobao.org
安装Ghost
清空网站根目录下所有文件(包括 .user.ini
,.htaccess
)
安装Ghost脚手架
npm i -g ghost-cli
安装Ghost博客环境
mkdir -p /www/wwwroot/test.com
cd /www/wwwroot/test.com
ghost install
### 具体步骤:
System checks failed with message: 'Missing
...
//对于本地安装,我们建议使用'本地安装Ghost'代替?
y
Local MySQL install .. MySQL host.
Alternatively you could:
a) install MySQL locally
...
install using sqlite3.
//未找到本地MySQL安装。如果您使用的是远程MySQL主机,则可以忽略它
y
? Enter your blog URL: (http://localhost:2368)
//输入你的博客链接
稍后在配置文件中修改,这里直接 回车
? Enter your MySQL hostname: (localhost)
//输入你的MySQL服务器
没有特殊情况 回车
? Enter your MySQL username:
//输入您的MySQL用户名
? Enter your MySQL password:
//输入您的数据库密码
? Enter your Ghost database name
//输入您的Ghost数据库名称
? Do you wish to set up Nginx? (Y/n)
//你想建立Nginx吗
y
? Do you wish to set up "ghost" mysql user? (Y/n)
//你想设置“Ghost”mysql用户吗?
y
? Do you wish to set up Systemd? (Y/n)
//你希望建立系统吗
y
Nginx配置
登录宝塔面板进入【网站】-> 选择test.com -> 【配置文件】清空所有配置,重写为:
server {
listen 80;
server_name test.com; //你的博客域名
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:2368;
}
}
Ghost配置文件
编辑 test.com 根目录下的 config.production.json
文件
{
"url": "http://test.com", //修改为你的域名
"server": {
"port": 2368,
"host": "127.0.0.1"
},
"database": {
"client": "mysql",
"connection": {
"host": "127.0.0.1",
"user": "数据库用户名",
"password": "数据库密码",
"database": "数据库名"
}
},
"mail": {
"transport": "Direct"
},
"logging": {
"transports": [
"file",
"stdout"
]
},
"process": "systemd",
"paths": {
"contentPath": "/www/wwwroot/test.com/content"
}
}
参考:
* https://iiong.com/ghost-ver-1-x-installation-notes.html
* https://sb.sb/debian-ubuntu-install-upgrade-ghost/