Ghost 是基于 Node.js 构建的开源博客平台。Ghost 具备易用的书写界面和体验,博客内容默认采用Markdown 语法 书写。Ghost 的目标是取代臃肿的 Wordpress。
一、本机测试环境html
[root@mingc ~]# cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core) [root@mingc ~]# uname -r 3.10.0-514.26.2.el7.x86_64
二、 安装Node.js node
#更新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)nginx
[root@mingc ~]# cnpm i -g ghost-cli #安装成功后经过运行 ghost -v,出现版本号便可表示安装成功。 [root@mingc ~]# ghost -v Ghost-CLI version: 1.7.1
②添加 Ghost 运行用户并建立目录sql
[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 默认就已经启动的npm
# 中止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/bash
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
后台管理页面:curl
以上搭建过程本人亲自操做可用,有问题可留言评论,抽空予以解答,以为有用点个赞,支持下做者!ide