Ghost介绍

Ghost 是基于 Node.js 构建的开源博客平台。Ghost 具有易用的书写界面和体验,博客内容默认采用Markdown 语法书写。Ghost 的目标是取代臃肿的 Wordpress。搭建Ghost博客系统

1、本机测试环境

[root@mingc ~]# cat /etc/redhat-releaseCentOS Linux release 7.2.1511 (Core)[root@mingc ~]# uname -r3.10.0-514.26.2.el7.x86_64

2、 安装Node.js

#更新yum源[root@mingc ~]# yum update -y#安装软件组包Development Tools[root@mingc ~]# yum groupinstall -y "Development Tools"#安装NodeSource Node.js 6.x repo[root@mingc ~]# curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -#yum安装 nodejs[root@mingc ~]# yum -y install nodejs#npm国内镜像(npm是随同NodeJS一起安装的包管理工具)[root@mingc ~]# npm config set registry https://registry.npm.taobao.org#安装cnpm模块(因为国内网络的关系,也同时安装了 cnpm 模块,后续将使用该命令代替 npm 命令。)[root@mingc ~]# npm i -g cnpm

#通过node -v 和npm -v命令查看是否安装成功。

3.、安装 ghost
①安装 Ghost Client (ghost-cli)

[root@mingc ~]# cnpm i -g ghost-cli#安装成功后通过运行 ghost -v,出现版本号即可表示安装成功。[root@mingc ~]# ghost -vGhost-CLI version: 1.7.1

②添加 Ghost 运行用户并创建目录

[root@mingc ~]# adduser ghost[root@mingc ~]# mkdir /var/www[root@mingc ~]# mkdir /var/www/ghost[root@mingc ~]# chown ghost /var/www/ghost

③安装SQLite3 数据库

#新版本不允许root用户安装,需要切换普通用户进行安装。[root@mingc ~]# su - ghost [ghost@mingc ~]$ cd /var/www/ghost[ghost@mingc ~]$ ghost install local --db=sqlite3

④启动 ghost
安装成功后 Ghost 默认就已经启动的

# 停止host[ghost@mingc ghost]$ ghost stop# 启动ghost[ghost@mingc ghost]$ ghost start#重启ghos[ghost@mingc ghost]$ ghost restart

安装成功后默认是运行在http://localhost:2368/
可使用如下方式访问:
[ghost@mingc ghost]$ curl http://localhost:2368/

4. 安装 Nginx和整合nodejs

[ghost@mingc ghost]$ su - root[root@mingc ~]# yum install -y nginx#启动 Nginx[root@mingc ~]# systemctl start nginx.service#查看nginx是否运行[root@mingc ~]# ps -ef|grep nginx#查看是否启动成功 http://你的ip

#设置开机自启动[root@mingc ~]# systemctl enable nginx.service#整合nodejs[root@mingc ~]#cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.ori[root@mingc nginx]# vi /etc/nginx/nginx.conf +47 server { ··· location / { proxy_pass http://127.0.0.1:2368; proxy_redirect default; root /usr/share/nginx/html; index index.html index.htm; } ···[root@mingc nginx]# nginx -s reload

4. 访问搭建的ghost博客
前台页面:http://你的ip/

后台登录页面:http://你的ip/ghost

后台管理页面:

以上搭建过程本人亲自操作可用,有问题可留言评论,抽空予以解答,觉得有用点个赞,支持下作者!