在CentOS上搭建基于Nodejs的Ghost博客
Ghost介绍Ghost 是基于 Node.js 构建的开源博客平台。Ghost 具有易用的书写界面和体验,博客内容默认采用Markdown 语法
书写。Ghost 的目标是取代臃肿的 Wordpress。
搭建Ghost博客系统
1、本机测试环境
# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
# uname -r
3.10.0-514.26.2.el7.x86_64
2、 安装Node.js
#更新yum源
# yum update -y
#安装软件组包Development Tools
# yum groupinstall -y "Development Tools"
#安装NodeSource Node.js 6.x repo
# curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -
#yum安装 nodejs
# yum -y install nodejs
#npm国内镜像(npm是随同NodeJS一起安装的包管理工具)
# npm config set registry https://registry.npm.taobao.org
#安装cnpm模块(因为国内网络的关系,也同时安装了 cnpm 模块,后续将使用该命令代替 npm 命令。)
# npm i -g cnpm
#通过node -v 和npm -v命令查看是否安装成功。
http://i2.运维网.com/images/blog/201804/23/da5e7b25e66b422ca4455ccbd252d654.png
3.、安装 ghost
①安装 Ghost Client (ghost-cli)
# cnpm i -g ghost-cli
#安装成功后通过运行 ghost -v,出现版本号即可表示安装成功。
# ghost -v
Ghost-CLI version: 1.7.1
②添加 Ghost 运行用户并创建目录
#adduser ghost
#mkdir /var/www
#mkdir /var/www/ghost
#chown ghost /var/www/ghost
③安装SQLite3 数据库
#新版本不允许root用户安装,需要切换普通用户进行安装。
# su - ghost
$cd /var/www/ghost
$ ghost install local --db=sqlite3
④启动 ghost
安装成功后 Ghost 默认就已经启动的
# 停止host
$ ghost stop
# 启动ghost
$ ghost start
#重启ghos
$ ghost restart
安装成功后默认是运行在http://localhost:2368/
可使用如下方式访问:
$ curl http://localhost:2368/
4. 安装 Nginx和整合nodejs
$ su - root
# yum install -y nginx
#启动 Nginx
# systemctl start nginx.service
#查看nginx是否运行
# ps -ef|grep nginx
#查看是否启动成功 http://你的ip
http://i2.运维网.com/images/blog/201804/23/27465b3d7089c1f36159b9c0773d2fc0.png
#设置开机自启动
# systemctl enable nginx.service
#整合nodejs
#cp /etc/nginx/nginx.conf/etc/nginx/nginx.conf.ori
# vi /etc/nginx/nginx.conf +47
server {
···
location / {
proxy_pass http://127.0.0.1:2368;
proxy_redirect default;
root /usr/share/nginx/html;
indexindex.html index.htm;
}
···
# nginx -s reload
4. 访问搭建的ghost博客
前台页面:http://你的ip/
http://i2.运维网.com/images/blog/201804/23/36cd6312ae56cfb4ba893e51162880f8.png
后台登录页面:http://你的ip/ghost
http://i2.运维网.com/images/blog/201804/23/60796e4ddc06c5019825f941edf98205.png
后台管理页面:
http://i2.运维网.com/images/blog/201804/23/d72c8c8e30eebedde8914dff11c70780.png
以上搭建过程本人亲自操作可用,有问题可留言评论,抽空予以解答,觉得有用点个赞,支持下作者!
页:
[1]