CentOS 7.5上安装Node.js搭建Ghost个人博客

Ghost简介

Ghost 是基于 Node.js 构建的开源博客平台,由前 WordPress UI 部门主管 John O’Nolan 和 WordPress 高级工程师(女) Hannah Wolfe 创立。Ghost 具有易用的书写界面和体验,博客内容默认采用Markdown 语法书写。Ghost 的目标是取代臃肿的 Wordpress。目的是为了给用户提供一种更加纯粹的内容写作与发布平台。

CentOS 7.5上安装Node.js搭建Ghost个人博客

开始搭建Ghost博客系统

1、本机测试环境

CentOS 7.5上安装Node.js搭建Ghost个人博客

2、 安装Node.js

#更新yum源
[root@mingc ~]# sudo yum update -y

CentOS 7.5上安装Node.js搭建Ghost个人博客

CentOS 7.5上安装Node.js搭建Ghost个人博客

#安装NodeSource Node.js 6.x repo
[root@localhost ~]# curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -

CentOS 7.5上安装Node.js搭建Ghost个人博客

#yum安装 nodejs
[root@localhost ~]# yum -y install nodejs

CentOS 7.5上安装Node.js搭建Ghost个人博客

#npm国内镜像(npm是随同NodeJS一起安装的包管理工具)
[root@localhost ~]# npm config set registry https://registry.npm.taobao.org
#安装cnpm模块(因为国内网络的关系,也同时安装了 cnpm 模块,后续将使用该命令代替 npm 命令。)
[root@localhost ~]# npm i -g cnpm

CentOS 7.5上安装Node.js搭建Ghost个人博客

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

[root@localhost ~]# node -v
v6.14.4
[root@localhost ~]# npm -v
3.10.10
[root@localhost ~]#

CentOS 7.5上安装Node.js搭建Ghost个人博客

3.、安装 Ghost

①安装 Ghost Client (ghost-cli)

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

CentOS 7.5上安装Node.js搭建Ghost个人博客

[root@localhost ~]# ghost -v
Ghost-CLI version: 1.9.6
[root@localhost ~]#

CentOS 7.5上安装Node.js搭建Ghost个人博客

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

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

CentOS 7.5上安装Node.js搭建Ghost个人博客

③安装SQLite3 数据库

#新版本不允许root用户安装,需要切换普通用户进行安装。

[root@localhost ~]# su - ghost
[ghost@localhost ~]$ cd /var/www/ghost

CentOS 7.5上安装Node.js搭建Ghost个人博客

[ghost@localhost ghost]$ ghost install local --db=sqlite3
✔ Checking system Node.js version
✔ Checking current folder permissions
✔ Checking memory availability
✔ Checking for latest Ghost version
✔ Setting up install directory
✔ Downloading and installing Ghost v2.3.0
✔ Finishing install process
✔ Configuring Ghost
✔ Setting up instance
ℹ Ensuring user is not logged in as ghost user [skipped]
ℹ Checking if logged in user is directory owner [skipped]
✔ Checking current folder permissions
✔ Validating config
✔ Checking memory availability
✔ Starting Ghost

Ghost uses direct mail by default. To set up an alternative email method read our docs at https://ghost.org/mail

------------------------------------------------------------------------------

Ghost was installed successfully! To complete setup of your publication, visit:

    http://localhost:2368/ghost/

CentOS 7.5上安装Node.js搭建Ghost个人博客

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

# 停止host
[ghost@localhost ghost]$ ghost stop
✔ Stopping Ghost

# 启动ghost
[ghost@localhost ghost]$ ghost start

#重启ghos
[ghost@localhost ghost]$ ghost restart

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

CentOS 7.5上安装Node.js搭建Ghost个人博客

4. 安装 Nginx和整合nodejs

[ghost@localhost ghost]$ su - root
[root@localhost ~]# yum install -y nginx
#启动 Nginx
[root@localhost ~]# systemctl start nginx.service
#查看nginx是否运行
[root@localhost ~]# ps -ef|grep nginx

CentOS 7.5上安装Node.js搭建Ghost个人博客

#查看是否启动成功 http://你的ip

CentOS 7.5上安装Node.js搭建Ghost个人博客

#设置开机自启动
[root@localhost ~]# systemctl enable nginx.service
#整合nodejs
[root@localhost ~]# 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@localhost ~]# nginx -s reload           

5. 访问搭建的ghost博客

前台页面:http://你的ip/

CentOS 7.5上安装Node.js搭建Ghost个人博客

host博客

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

CentOS 7.5上安装Node.js搭建Ghost个人博客

后台管理页面:

CentOS 7.5上安装Node.js搭建Ghost个人博客

Ghost作为一个新兴的博客系统肯定会有一些不足,但是我们相信它会越来越好的,希望大家都能用它来记录生活中一些美好的时刻,分享自己的精彩的创意,共同建立并且维护这样一个和谐的互联网大家庭。

以上搭建过程本人亲自操作可用,有问题可留言评论。

猜你喜欢

转载自www.linuxidc.com/Linux/2018-10/155071.htm