你好,游客 登录 注册 搜索
背景:
阅读新闻

CentOS 7.2 搭建 Ghost 博客

[日期:2016-11-20] 来源:Linux社区  作者:Irving [字体: ]

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

linux
相关资讯       Ghost 博客 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款