美文网首页
Install Ghost Blog on CentOS

Install Ghost Blog on CentOS

作者: lenicliu | 来源:发表于2016-04-17 20:36 被阅读0次

    Install nodejs(Required)

    tar zxvf node-v0.10.40-linux-x86.tar.gz
    ln -s /{node_install_path}/bin/node /usr/local/bin/node
    ln -s /{node_install_path}/bin/npm /usr/local/bin/npm
    
    • check version, node -v & npm -v

    Install ghost(Required)

    • download ghost-latest.zip
    • unzip -uo ghost-latest.zip -d ghost
    • execute cmd npm install --production in ghost folder.
    • modify config.js, remove the unused options
    var path = require('path'), config;
    config = {
        production: {
            url: 'http://www.mydomain.com',
            mail: {},
            database: {
                client: 'sqlite3',
                connection: {
                    filename: path.join(__dirname, '/content/data/ghost.db')
                },
                debug: false
            },
            server: {
                host: '127.0.0.1',
                port: '2368'
            }
        }
    };
    
    module.exports = config;
    

    Run ghost

    Nginx & Domain(Optional)

    • install nginx : yum install nginx
    • modify /etc/nginx/conf.d/default.conf, don't forget backup the file :)
    server {
        listen       80;
        server_name  www.mydomain.com;
    
        charset utf-8;
        access_log  /var/log/nginx/log/host.access.log  main;
    
        location / {
            proxy_set_header   X-Real-IP $remote_addr;
            proxy_set_header   Host      $http_host;
            proxy_pass         http://127.0.0.1:2368;
            proxy_set_header   REMOTE-HOST $remote_addr;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        }
    }
    
    • restart nginx service nginx restart
    • don't forget to setup the domain on DNS provider.

    Forever(Recommend)

    • execute cmd npm install forever -g
    • create shell script ghost.sh
    NODE_ENV=production forever start index.js
    
    • create shell script ghost-stop.sh
    forever stop index.js
    

    Usage

    • sh ghost.sh for startup
    • sh ghost-stop.sh for shutdown

    Enjoy it :)

    相关文章

      网友评论

          本文标题:Install Ghost Blog on CentOS

          本文链接:https://www.haomeiwen.com/subject/qawolttx.html