腾讯云VPS安装Ghost博客过程

各种系统下安装的教程有很多,但是到了更具体的系统环境下,仍然可能会多出一些问题,为了方便新手学习Ghost blog的安装过程,记录下这篇文章。整个流程基本都一样,但是会出现一些细节问题,主要还是以下几个方面需要注意:

新版本安装方法有较大改动,请参考官方文档进行安装。

  1. nodejs的安装,需要安装Ghost支持的版本。
  2. Ghost的安装。国内网络的特色,导致npm安装失败

以下过程演示在腾讯云Ubuntu14.04 x86系统上,不同的系统可能有细微的差别。

一、环境安装

sudo apt-get update sudo apt-get install nodejs npm nginx -y

执行完成上列命令后,使用node -v命令查询node版本,到Ghost的Github页面查询支持的版本,确认版本无误。如果命令报错”找不到命令”,不要着急,添加一条软链接即可解决。

sudo ln -s /usr/bin/nodejs /usr/bin/node

二、Ghost的安装

这里是使用Ghost Blog China 制作的中文版本,其中含有一些中国特色的功能,例如七牛云图床等,为了避免之后的麻烦,这里选择使用集成node_modules的完整版,

sudo mkdir /var/www 
cd /var/www 
sudo wget http://dl.ghostchina.com/Ghost-0.7.4-zh-full.zip 
sudo unzip Ghost* -d ghost 
cd ghost 
sudo npm install node-pre-gyp -g 
sudo npm install sqlite3 forever

安装部分到这里就算完成了,接着稍微配置一下,sudo vim config.js,编辑my-ghost-blog成自己的域名,保存退出,接着执行NODE_ENV=production forever start index.js,使用forever以生产模式运行Ghost。

三、Nginx配置

sudo vim /etc/nginx/sites-available/ghost.conf

加入下列内容,修改example成自己的域名:

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; 
    } 
}
sudo ln -s /etc/nginx/sites-available/ghost.conf /etc/nginx/sites-enabled/ghost.conf
sudo service nginx restart

添加软链接,重启Nginx生效。当然,还需要域名添加一条a记录指向自己的VPS IP。

相关内容:


评论

《 “腾讯云VPS安装Ghost博客过程” 》 有 2 条评论

  1. 原来是npm没有装好

    1. 安装npm好像没什么困难吧

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注