再看最后一眼青春的星空

灿烂火光就像盛夏的烟火

欢送挣扎万年文明的巅峰

我们啊

将变星辰永远飘在黑暗宇宙

这个男人来自三体

Tirion

导航

安装 Ghost 博客和 Nginx

Ghost 认 node 的版本,所以使用 nvm 更好。

1、安装 nvm:

可以去 github 查看 nvm 的说明,通过:wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash 这样的方式下载安装。

2、安装 Ghost 和 unzip

安装 Ghost:curl -L https://ghost.org/zip/ghost-latest.zip -o ghost.zip 下载最新版 Ghost(如果无法现在,换 wget 命令)

安装 unzip:yum install zip unzip 安装 zip 和 unzip 命令

解压 Ghost:unzip -uo ghost.zip -d ghost

3、配置 Ghost:进入 ghost 目录,修改 config.js 文件里的

    production: {
        url: 'http://www.tirion.me',  // 修改这里即可
        mail: {},
        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost.db')
            },
            debug: false
        },

        server: {
            host: '127.0.0.1',
            port: '2368'
        }
    },

4、安装 Nginx:yum install nginx

nginx 常用命令:

service nginx start

service nginx restart

service nginx reload

5、配置 Nginx:

cd /etc/nginx 进入 Nginx 目录

cat nginx.conf 可以看到:

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;  // 这里可以看到加载的配置文件目录,网上多为 sites-enabled 目录,但是我的是 conf.d 目录
}

cd conf.d 进入配置目录,里面有 default.conf,可以删掉,然后创建自己的 conf。

6、创建 ghost.conf 配置文件:

server {
    listen 80;  // 监听的端口
    server_name www.tirion.me;  // 请求的域名
    charset utf-8;
    location / {
        proxy_pass http://127.0.0.1:2368;  // 解析到 ghost 的端口
    }
}

7、重启 Nginx 生效配置:

service nginx reload

8、安装 forever,可后台运行 node 服务

npm install forever -g

forever 常用命令:

  forever start node文件

  forever stop node文件

9、启动 Ghost 服务

进入安装的 ghost 目录,运行:

NODE_ENV=production forever start index.js

10、访问项目:

通过 www.tirion.me 即可访问 ghost 博客了。

 

其它:

使用 MySQL:http://www.ghostchina.com/install-ghost-on-ali-ecs-third-step-install-mysql/

posted on 2016-12-13 19:27  Tirion  阅读(815)  评论(0编辑  收藏  举报

The Man from 3body