首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >CentOS搭建Ghost博客

CentOS搭建Ghost博客

作者头像
互联网-小阿宇
发布2022-11-21 19:17:28
2830
发布2022-11-21 19:17:28
举报
文章被收录于专栏:互联网-小阿宇互联网-小阿宇

参考:腾讯云手动实验https://cloud.tencent.com/developer/labs/lab/10281

Ghost 是一款非常出色的开源博客平台,界面简洁,专注写作。CentOS 7 上安装 Ghost ,包括安装 Nodejs 环境以及配置 Nginx 对 Ghost 的代理请求等步骤。

安装Node.js及相关包

限制使用node.js版本^8.16.0 || ^10.13.0 || ^12.10.0

[root@localhost ~]# yum -y update
[root@localhost ~]# yum groupinstall -y "Development Tools" \
--setopt=group_package_types=mandatory,default,optional
[root@localhost ~]# wget https://npm.taobao.org/mirrors/node/v12.16.2/node-v12.16.2-linux-x64.tar.xz
[root@localhost ~]# tar xf node-v12.16.2-linux-x64.tar.xz 
[root@localhost ~]# mv node-v12.16.2-linux-x64 /usr/local/nodejs
[root@localhost ~]# vim /etc/profile
# 末尾添加
export PATH=$PATH:/usr/local/nodejs/bin
[root@localhost ~]# source /etc/profile
[root@localhost ~]# node -v
v12.16.2
[root@localhost ~]# npm -v
6.14.4
[root@localhost ~]# npm config set registry https://registry.npm.taobao.org
[root@localhost ~]# npm i -g cnpm

安装成功后通过运行node -v及npm -v 出现版本号即可表示安装成功。

因为国内网络的关系,也同时安装了 cnpm 模块,后续将使用该命令代替 npm 命令。

安装Ghost Client

[root@localhost ~]# cnpm i -g ghost-cli
...
[ghost-cli@1.13.1] link /usr/bin/ghost@ -> /usr/lib/node_modules/ghost-cli/bin/ghost
[root@localhost ~]# ghost -v
Ghost-CLI version: 1.13.1

一般而言,安装成功后通过运行 ghost -v,出现版本号即可表示安装成功。但因为国内的网络问题,安装后请检查下终端的 log,如果有出现任意红色报错信息,则证明只有部分安装成功,需要重新执行命令安装。

安装Ghost 添加Ghost程序用户,并创建目录

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

安装Ghost

[root@localhost ~]# su ghost
[ghost@localhost root]$ 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 v3.14.0
✔ Finishing install process
✔ Configuring Ghost
✔ Setting up instance
✔ Starting Ghost

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

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

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

    http://localhost:2368/ghost/

启动Ghost

[ghost@localhost ghost]$ ghost start
Ghost is already running! For more information, run: 
    ghost ls
[ghost@localhost ghost]$ ghost ls
┌─────────────┬────────────────┬─────────┬───────────────────────┬────────────────────────┬──────┬─────────────────┐
│ Name        │ Location       │ Version │ Status                │ URL                    │ Port │ Process Manager │
├─────────────┼────────────────┼─────────┼───────────────────────┼────────────────────────┼──────┼─────────────────┤
│ ghost-local │ /var/www/ghost │ 3.40.5  │ running (development) │ http://localhost:2368/ │ 2368 │ local           │
└─────────────┴────────────────┴─────────┴───────────────────────┴────────────────────────┴──────┴─────────────────┘

安装nginx 配置yum源

[ghost@localhost ghost]$ exit
exit
[root@localhost ~]# rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

安装nginx

[root@localhost ~]# yum -y install nginx

启动nginx

[root@localhost ~]# systemctl start nginx

配置反向代理 修改nginx配置文件

[root@localhost ~]# vim /etc/nginx/conf.d/default.conf
    location / {
        proxy_pass http://127.0.0.1:2368;
        proxy_redirect default;
        root    /usr/share/nginx/html;
        index   index.html index.htm;
    }

重启nginx

[root@localhost ~]# nginx -s stop 
[root@localhost ~]# nginx

验证 访问http://192.168.1.10/ghost/

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

http://192.168.1.10

在这里插入图片描述
在这里插入图片描述
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2021-01-08,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 安装Node.js及相关包
    • 安装Ghost Client
    领券
    问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档