CentOS7.5上安装Node.js搭建Ghost个人博客

Ghost简介

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

郧西网站建设公司创新互联公司,郧西网站设计制作,有大型网站制作公司丰富经验。已为郧西上千家提供企业网站建设服务。企业网站搭建\成都外贸网站建设公司要多少钱,请找那个售后服务好的郧西做网站的公司定做!

开始搭建Ghost博客系统

1、本机测试环境

2、 安装Node.js

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

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

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

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

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

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

3.、安装 Ghost

①安装 Ghost Client (ghost-cli)

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

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

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

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

③安装SQLite3 数据库

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

[root@localhost ~]# su - ghost
[ghost@localhost ~]$ cd /var/www/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/

④启动 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/

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

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

#设置开机自启动
[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/

host博客

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

后台管理页面:

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

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

分享标题:CentOS7.5上安装Node.js搭建Ghost个人博客
文章来源:http://www.shufengxianlan.com/qtweb/news23/155773.html

网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联