首页 博客 文档 标签 归档 分类 示例文章 更新记录
osx下使用Ghost搭建博客 - SasSPro | 优秀的 Emlog 文档展示模板 | 高效管理与展示解决方案
首页 博客 文档 标签 归档 分类 示例文章 更新记录

osx下使用Ghost搭建博客

2016-06-07 · 管理员 · 阅读 4798

搭建流程

1.下载Ghost博客源码。

wget https://ghost.org/archives/ghost-0.8.0.zip
unzip ghost-0.8.0.zip -d ghost
cd ghost

2.安装依赖

请确保您的node版本为LTS 0.10.x, 0.12.x and 4.2+

npm install --production

启动Ghost

npm start --production

3.修改配置

将根目录config.js中production配置项urlmail设置好

production: {
    url: 'https://my-ghost-blog.com',
    mail: {
    transport: 'SMTP',
    options: {
    service: 'smtp.126.com',
    auth: {
    user: '', // 126 username
    pass: ''  // 126 password
    }
    }
    },
    ...

4.配置nginx

nginx安装教程

brew install nginx

安装好后运行

sudo nginx

启动之后可以通过 https://localhost:8080 来访问站点。

配置你的nginx

编辑nginx配置文件/usr/local/etc/nginx/nginx.conf 修改server相关配置

server {
     listen 80;
     server_name my-ghost-blog.com;

     location / {
         proxy_set_header   X-Real-IP $remote_addr;
         proxy_set_header   Host      $http_host;
         proxy_pass         https://127.0.0.1:2368;
     }
 }

重启nginx

sudo nginx -s stop
sudo nginx

测试
更改 /etc/hosts,使 my-ghost-blog.com 指向 127.0.0.1
在浏览器中访问 https://my-ghost-blog.com 即可打开Ghost博客。

5.运行forever

此时虽然可以通过nginx访问到Ghost博客。但是npm是运行在终端上的,终端一旦关闭,npm的服务就会停止运行。通过自己的域名就无法访问到Ghost博客。为了防止 Ghost 停止工作,我们可以使用npm包forever来解决这个问题。
https://npmjs.org/package/forever

安装 forever

npm install forever -g

运行 forever

在Ghost根目录运行
NODE_ENV=production forever start index.js

停止 forever

forever stop #id(这个id可以通过forever list查看到)

查看运行着的 forever

forever list

这是在本地运行的Ghost,通过这个教程,也可以在vps上搭建。仅需将更改 hosts 这一步改为域名绑定。一般vps的控制面板都会有域名绑定的功能。

更多Ghost配置见官方文档

上一篇 Samsung Galaxy Note5 三星note5相册里不显示图片 下一篇 javascript中要避免与 null 进行比较
管理员

emlog模版beginning开发者

评论交流 (0)

暂无评论,来坐第一个沙发吧~

发表评论