把WP移到了Ghost,以下是我安装Ghost的过程。
下载安装Ghost安装包
- 获取最新安装包
1
| curl -L https://ghost.org/zip/ghost-latest.zip -o ghost.zip
|
- 解压安装包
1
| unzip -uo ghost.zip -d /var/www/skyf
|
note: 把skyf换成自己的网站目录。
- 进入网站目录,并安装产品依赖包
1
| cd /var/www/skyf && npm install --production
|
修改配置文件
修改更目录下 config.js 文件 production 配置:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| production: { url: 'http://www.skyf.org', mail: {},
database: { client: 'mysql', connection: { host : 'localhost', user : process.env.DB_USER, password : process.env.DB_PASSWORD, database : process.env.DB_NAME, charset : 'utf8' }, debug: false },
server: { host: '127.0.0.1', port: '5322' } }
|
然后在Nginx做如下配置
在nginx配置目录里,新建conf文件,做如下配置:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| server { listen 80;
server_name skyf.org www.skyf.org;
if ($host != 'www.skyf.org') { rewrite ^/(.*)$ http://www.skyf.org/$1 permanent; }
location / { proxy_pass http://127.0.0.1:5322; }
location /f { index index.html; alias /var/www/skyf/content/custom; }
location /demo { index index.html index.htm; alias /var/www/skyf/content/demo; access_log off; expires max; }
location /static { index index.html index.htm; alias /var/www/skyf/content/static; access_log off; expires max; } }
|
然后重启nginx服务。
启动网站
到Ghost网站目录下,并启动Ghost:
然后通过域名便可访问ghost.
初始化后台
直接访问 http://域名/ghost 便可以初始化后台。
- 在你当前的主题目录找到 post.hbs 文件,如:yourghostdir/content/themes/casper/
- 粘贴如下代码到
</article> 标签前面
1 2 3 4 5 6 7 8 9 10 11 12 13
| <div id="disqus_thread"></div> <script type="text/javascript"> var disqus_shortname = 'example';
(function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })(); </script> <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript> <a href="http://disqus.com" class="dsq-brlink">comments powered by Disqus</a>
|
- 替换disqus_shortname为你的Disqus forum shortname.
- 重启Ghost即可。
使用PM2后台运行Ghost
安装 PM2,以 CentOS 为例
- 通过
npm install pm2@latest -g 安装PM2 - 为了让PM2自启动,使用
pm2 startup centos - 然后以生产模式,启动Ghost
NODE_ENV=production pm2 start index.js --name ghost.skyf - 保存
pm2 save - 然后重新启动 Ghost
pm2 restart index.js - 通过
pm2 list 可以检查Ghost是否在运行
这样Ghost就可以一直驻守在后台了。同样的插件有 Supervisor、Forever。