Fork me on GitHub

CentOS 7.2 搭建 Ghost 博客

因为平时记录一些文档或想法基本使用 markdown 的语法,Mac 下推荐一款 markdown 的编辑器 Haroopad;上周无意发现 Ghost 有支持 Mac 的桌面版本了,并且同样开源 https://github.com/tryghost/ghost-desktop ,这样后面记录一些文档也可以同步到网络上就很方便了,于是重新搭建了一个。

Ghost 是基于 NodeJS 的开源博客平台,由前 WordPress UI 部门主管 John O’Nolan 和 WordPress 高级工程师(女) Hannah Wolfe 创立,目的是为了给用户提供一种更加纯粹的内容写作与发布平台。
#配置 NodeJS 环境
wget https://nodejs.org/dist/v6.9.1/node-v6.9.1-linux-x64.tar.xz
tar -xvf node-v6.9.1-linux-x64.tar.xz
#配置环境变量
vi /etc/profile
#输入保存

#set for nodejs
export NODE_HOME=/opt/node-v6.9.1-linux-x64
export PATH=$NODE_HOME/bin:$PATH
export NODE_PATH=$NODE_HOME/lib/node_modules:$PATH

#保存退出
:wq
#生效
source /etc/profile
#检查是否安装成功
node -v
npm –v
#安装Chost
wget https://ghost.org/zip/ghost-0.11.3.zip
unzip -uo ghost-0.11.3.zip -d ghost
#更换源
npm install -g cnpm --registry=https://registry.npm.taobao.org
#更换默认db为 MySQL
cp config.example.js config.js
vi config.js

    // ### Production  修改为使用 MySQL 数据库
    // When running Ghost in the wild, use the production environment
    // Configure your URL and mail settings here
    production: {
        url: 'http://my-ghost-blog.com',
        mail: {},
        database: {
            client: 'mysql',
            connection: {
                host     : '127.0.0.1',
                user     : 'username', //用户名
                password : '', //密码
                database : 'ghost', //数据库名
                charset  : 'utf8'
            }
        },
        server: {
            // Host to be passed to node's `net.Server#listen()`
            host: '127.0.0.1',
            // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
            port: '2368'
        }
    },

#启动
yum install screen
screen -S ghost
cnpm install --production
cnpm start --production
#安装Nginx
#http://nginx.org/en/download.html
#安装编译库及依赖模块
yum -y install gcc gcc-c++ autoconf automake make
yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel
#安装
cd /opt
wget http://nginx.org/download/nginx-1.10.2.tar.gz
tar zxvf nginx-1.10.2.tar.gz
cd nginx-1.10.2
./configure --prefix=/opt/nginx --with-http_stub_status_module --with-http_gzip_static_module
make && make install
#测试配置文件是否有错误
/opt/nginx/sbin/nginx -t
#重新加载配置
/opt/nginx/sbin/nginx -s reload
#启动nginx
/opt/nginx/sbin/nginx
#停止nginx
/opt/nginx/sbin/nginx -s stop
#配置HTTPS 模块
// --with-http_ssl_module
#配置

复制代码
server {
    listen 80;
    server_name example.com;

    location / {
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Host      $http_host;
        proxy_pass         http://127.0.0.1:2368;
    }
}
复制代码

#未解决问题
- forever 跟阿里 NodeJS 版本有点冲突
- CENTOS 7.2 下配置 supervisor 有些问题 暂时使用 screen 代替
[program:ghost]
command = node /opt/ghost/index.js
directory = /opt/ghost
user = root
autostart = true
autorestart = true
stdout_logfile = /var/log/supervisor/ghost.log
stderr_logfile = /var/log/supervisor/ghost_err.log
environment = NODE_ENV="production"

REFER:
http://docs.ghostchina.com/zh/installation/deploy/
进程管理supervisor的简单说明
http://www.cnblogs.com/zhoujinyi/p/6073705.html
如何搭建一个Ghost平台的博客?
https://www.zhihu.com/question/22755373
「搭建Ghost博客」经典教程
https://segmentfault.com/a/1190000002947497

posted @   花儿笑弯了腰  阅读(1527)  评论(0编辑  收藏  举报
编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· .NET周刊【3月第1期 2025-03-02】
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· [AI/GPT/综述] AI Agent的设计模式综述
点击右上角即可分享
微信分享提示