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

CentOS 7.2 搭建 Ghost 博客

111次阅读
没有评论

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

因为平时记录一些文档或想法基本使用 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”

CentOS 7 系统安装 Ghost 博客平台  http://www.linuxidc.com/Linux/2016-10/136410.htm

CentOS6 32 位安装 Ghost http://www.linuxidc.com/Linux/2015-09/123063.htm

本文永久更新链接地址 :http://www.linuxidc.com/Linux/2016-11/137336.htm

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