作死集

A 1 post collection


半夜救回Ghost....

 •  Filed under Ghost, 作死集

真不容易啊....明天早上还有高数,寝室里只有飞飞睡了,剩下三个里两个在做课设,我在拯救我的Ghost博客.....

起因是手贱重启了Ghost服务,然后就发现访问域名80端口就呵呵了....直接502,但是域名+:2368是可以访问的,说明Ghost至少还在2368端口正常工作。

然后看Nginx的ERROR.LOG里是这么写的:

connect() failed (111: Connection refused) while connecting to upstream

这个其实和upstream的内容没太大关系...至少是我这种状况是没啥关系,和9000端口更没关系。

解决方案

这里有两点:

1.有关重启后内容消失了的问题

很大可能是模式设置的问题。我才发现我的文章都是在Development模式下的Ghost发表的,因此当我重启时,先执行停止:

forever stop index.js

然后启动要选择development而不是production

NODE_ENV=development forever start index.js

否则你会发现你的网页什么都没有了....一篇文章也不显示,因为你现在在另外一个你没有发过文章的模式下。

2.有关端口的问题

如果Nginx里设置了2368转发80端口,那么Ghost里面的config.js就千万不要在host这个地方填写VPS的外网IP,要写127.0.0.1,否则502死死的

参见 digitalocean-community 的第一个回复:

Once nginx was configured, I was getting the Gateway error because both ghost and nginx where now listening at different ports and nginx was redirecting to the server's localhost address at port 2368.The problem here was the Ghost's config.js was still using the server's IP, rather than the localhost address.

Anyways, once I change the Ghost config.js file's "host" address back to the localhost 127.0.0.1, everything worked.

3.(另一个不算bug的问题)

注:已经解决:看这个

我用的DISQUS评论服务,我分享到朋友圈的时候我的网页后面会带一个参数from=timeline&isappinstalled=0
这导致了DISQUS会认为在from=timeline&isappinstalled=0这个页面才有评论,而真正没有参数的页面不显示评论。这不是坑爹么....

于是我收到邮件说有人评论我的网站了 然后我从朋友圈点开链接是能看到陈叔的评论 但是从电脑上就看不到了...

或者说这是Ghost和DISQUS结合的问题,导致了有参数和没参数的网页没有合并在一个评论列表里,测试后发现:

80端口和2368端口是同一网页但是识别为两个页面

http://www.justzht.com:2368/facebookpaperprojext/
http://www.justzht.com/facebookpaperprojext/

后面加上参数,比如Key=XXXX....也不能识别成一个

http://www.justzht.com:2368/facebookpaperprojext/
http://www.justzht.com:2368/facebookpaperprojext/from=timeline&isappinstalled=0 

甚至连带不带/,比如这种一个跳转的东西都无法合并

http://www.justzht.com/facebookpaperprojext
http://www.justzht.com/facebookpaperprojext/