部署环境
CentOS7.2 1核1G-
安装g++编译器
- yum update -y
- yum list gcc-c++
- yum install gcc-c++.x86_64 -y
-
安装Nodejs
目前Node.js v4.2.0 LTS 已经成为Ghost推荐版本- wget https://nodejs.org/download/release/v4.2.0/node-v4.2.0.tar.gz
- tar zxvf node-v4.2.0.tar.gz
- cd node-v4.2.0
- ./configure
- make && make install
编译安装大约15分钟
-
安装Nginx
- vi /etc/yum.repos.d/Nginx.repo
写入以下内容
安装Nginx
- yum install Nginx -y
运行Nginx
- systemctl start Nginx
- vi /etc/Nginx/conf.d/ghost.conf
写入以下内容
- server {
- listen 80;
- server_name example.com; #将 example.com 改为自己的域名
- location / {
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header Host $http_host;
- proxy_pass http://127.0.0.1:2368;
- }
- }
重启Nginx
- systemctl restart Nginx
设置为开机启动
- systemctl enable Nginx
-
安装MariaDB
- sudo yum install mariadb-server -y
- sudo systemctl enable mariadb
- sudo systemctl start mariadb
- sudo MysqL_secure_installation
登录MariaDB
- MysqL -u root -p
使用
q
来退出为了避免数据库存放的中文是乱码,我们还需要设置MysqL的编码
- vi /etc/my.cnf
写入以下内容
重启MariaDB
- systemctl restart mariadb
新建一个数据库,用来存放Ghost博客的数据
登录数据库MysqL -u root -p
创建ghost数据库create database ghost;
新建一个用户ghost,密码为123456grant all privileges on ghost.* to 'ghost'@'%' identified by '123456';
让权限生效flush privileges;
-
安装Ghost(Ghost v0.7.4 full (zh))
- mkdir /var/www && cd /var/www
- wget http://dl.ghostchina.com/Ghost-0.7.4-zh-full.zip
- unzip Ghost-0.7.4-zh-full.zip -d ghost
- cd ghost
- cp config.example.js config.js
配置文件
vi config.js
Ghost有产品模式、开发模式和测试模式等多种运行模式,这里我们需要在配置文件中找到production模式,如下图所示见证奇迹的时刻(启动Ghost)
- npm start --production
让 Ghost 一直运行
参考Ghost中文社区的文章 http://docs.ghostchina.com/zh...参考资料
https://www.linode.com/docs/d...
https://snowz.me/how-to-insta...
http://www.loyalsoldier.me/de...
http://docs.ghostchina.com/zh...