zoukankan      html  css  js  c++  java
  • 从零开始,CentOS6安装ghost博客

    买了个Bandwagon的VPS来科学上网的,寻思着空间还大顺便做个博客呗.

    然后就安装了AMH面板,再搞了个wordpress博客玩玩.

    接触到Ghost博客的时候,心血来潮想装一个. 然后就试着搞了.

    附上个人认为最好的教程.

    安装之后在Ngnix反向绑定域名之后,首页没格式了都乱了. 也不知道哪里出了问题.

    干脆推倒重来,重新给VPS装上了CentOS6x32系统. 接下来就是我一步步安装到位的过程:

    一. 首先用Xshell登陆SSH VPS

    安装LMNP环境包,具体看下面链接

    http://lnmp.org/install.html

    二. 检查更新CentOS

    yum update -y

    yum install -y wget

    三. 安装Node.js

    curl -sL https://rpm.nodesource.com/setup | bash -

    yum install -y nodejs

    四. 安装Ghost

    cd /home/wwwroot/

    curl -L -O http://dl.ghostchina.com/Ghost-0.7.4-zh.zip

    unzip -d ghost Ghost-0.7.4-zh.zip

    cd ghost

    sudo npm install --production

    五. 修改配置

    sudo vi config.example.js

    在Production下修改

    url:http://betears.com

    host: '127.0.0.1:2368'

    改为

    host: '0.0.0.0:2368'

    六. 创建ghost用户并登入

    useradd ghost

    chown -R ghost:ghost /home/wwwroot/ghost/

    su - ghost

    cd /home/wwwroot/ghost/

    npm start --production

    然后就打开链接

    http://betears.com:2368

    就可以看到安装完毕的ghost博客了.

    七. 以生产模式运行Ghost

    我们不能让其运行在开发模式. 需要让其运行在生产模式,且当其运行进程退出时自动重启. 因此我们可以使用强大的进程守护程序“PM2”达到此目的. (也可以使用Forever)进入到刚才的Ghost安装目录 执行下面的命令安装PM2:

    cd /home/wwwroot/ghost/

    sudo npm install pm2 -g

    我们要设置环境变量为“production”生产模!“index.js”是程序启动的入口. 最后给这个PM2的进程命名为"Ghost" 于是,执行下面的命令:

    NODE_ENV=production pm2 start index.js --name "ghost"

    让PM2知道在开机后自动运行我们的网站:

    pm2 startup centos pm2 save

    八. Ngnix反向绑定域名

    创建ghost.conf

    Vim /usr/local/nginx/conf/vhost/ghost.conf

    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; } }

    保存退出:wq

    最后 nginx -s reload

    修改配置后重新加载生效. 打开网站OK

  • 相关阅读:
    如何用nodejs创建一个proxy 服务
    企业包分发-应用内安装时碰到的问题
    React-Native与Weex的比较
    前端炫酷动画展示利器(lottie)
    记录一个web开发工具集网页
    git 和 远程分支关联
    reference to 'X' is ambiguous 解决
    mac 下解压 .bin文件
    fabric 集成trello
    ES6 对象的创建及操作
  • 原文地址:https://www.cnblogs.com/crazyacking/p/5136351.html
Copyright © 2011-2022 走看看