MENU

Ghost博客搭建教程【小白教程】

December 13, 2016 • Read: 5601 • 网站源码,网络笔记

前言

最近一款比较火的博客程序,一直以来也是我使用的博客程序。创造者是从 WordPress 工作下的一名攻城狮,不过转做了 ghost 博客,为提供更方便的写文。

注意:虽然网络上流传了很多 Ghost 博客一键安装包,但是不方便维护也不方便使用,出现了错误无法找到。所以本人不推荐使用 Ghost 一键安装包,不过如果你想用,只要 Google 一下就能找到了。

开始

准备

  1. VPS 一台(本次教程使用的是 128MBVPS 位点新西泽)如果你缺 VPS 可以找我购买,只要 150¥/ 年
  2. xshell(SSH 链接工具)
  3. Ghost0.7.2 中文版

首先你要 SSH 链接上你的 VPS

然后让我们安装 Nodo.js  因为 ghost 使用的是 node.js 并且还需要 Nginx 服务器作为反代

1. 安装 Nginx 以及必备环境

  • 1.yum -y install wget screen curl python
  • 2.wget http://mirrors.linuxeye.com/oneinstack.tar.gz 
  • 3.tar xzf oneinstack-full.tar.gz
  • 4.cd oneinstack
  • 5. ./install.sh

其中安装了 Nginx 服务器,MySQL 数据库,PHPmyadmin 数据库可视化操作(如果需要必须勾选安装 PHP,版本随便)其他的全都选 N    等待大约半小时就能安装完成。然后我们就进行下一步

2. 安装 node.js

这里我们使用的是 node.js 管理工具 NVM

1.curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.1/install.sh | bash(安装好这个后需要重启VPS)

2.nvm install v4.2.0(安装node.js 4.2.0)

安装虚拟主机

cd /root/oneinstack

./vhost.sh

下载 ghost 中文版  需要你进入虚拟主机安装。cd /data/wwwroot/你的域名

下载 wget http://dl.ghostchina.com/Ghost-0.7.4-zh-full.zip

解压 unzip Ghost-0.7.4-zh-full.zip

其中我们要重命名 config 文件 mv config.example.js config.js 并且利用 vi 修改 config 文件 vi config.js

我们找到生产环境的配置:production 将 url 修改成你的域名

你的数据库管理地址是:http://IP/phpMyAdmin

设置好后按 Ese 后输入:wq保存

3. 配置 Nginx 作为反向代理

你的 Nginx 配置在 /usr/local/nginx/conf/vhost目录下

这里你可以使用 vi 也可以使用 winscp 编辑  (自行百度)

配上我自己使用的.conf

server {

listen 80;

server_name My-Ghost-Blog.com;

location / { proxy_set_header X-Real-IP $remote_addr;

proxy_set_header Host $http_host;

proxy_pass http://127.0.0.1:2368;

      }

}

编辑好后,需要输入 reboot  重启你的 VPS

4. 安装 PM2 守护 ghost 程序

// 首先进到 ghost 的安装目录

// 安装 pm2 1.npm install pm2 -g

// 让 ghost 以 production 模式运作,指定程序的入口 index.js,并且此进程命名为 ghost

2.NODE_ENV=production pm2 start index.js --name "ghost" //

开机启动 3.pm2 startup centos

4.pm2 save

完成

现在输入 http://IP(域名)/ghost 来安装你的 ghost 博客吧!

Last Modified: March 16, 2017
Archives QR Code Tip
QR Code for this page
Tipping QR Code
Leave a Comment

3 Comments
  1. 曾经玩儿博客只是为了爽

    1. 空白网络 空白网络

      @凯哥自媒体 Ghost 博客对于专注写文字的人还是蛮不错的选择的

  2. 白菜 白菜

    脚印。。。。