阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

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

138次阅读
没有评论

共计 3094 个字符,预计需要花费 8 分钟才能阅读完成。

Ghost 简介

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

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

开始搭建 Ghost 博客系统

1、本机测试环境

[linuxidc@localhost ~]$ cat /etc/RedHat-release
CentOS Linux release 7.5.1804 (Core)
[linuxidc@localhost ~]$ uname -r
3.10.0-862.el7.x86_64

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

2、安装 Node.js

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

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

# 安装软件组包 Development Tools
[linuxidc@localhost ~]$ sudo yum groupinstall -y “Development Tools”

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

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

正文完
星哥说事-微信公众号
post-qrcode
 
星锅
版权声明:本站原创文章,由 星锅 2022-01-21发表,共计3094字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中