CentOS 7.2 搭建 Ghost 博客

由於平時記錄一些文檔或想法基本使用 markdown 的語法,Mac 下推薦一款 markdown 的編輯器 Haroopad;上週無心發現 Ghost 有支持 Mac 的桌面版本了,而且一樣開源 https://github.com/tryghost/ghost-desktop ,這樣後面記錄一些文檔也能夠同步到網絡上就很方便了,因而從新搭建了一個。html

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
#輸入保存node

#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
#配置mysql

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"linux

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/1190000002947497nginx

相關文章
相關標籤/搜索