ghost博客一直是welcome to nginx
发布于 8 年前 作者 hunteryourlove 9667 次浏览 来自 问答

大家好! 我使用的是阿里云Ubuntu 12x+32位系统,安装的mysql+nginx 在/srv/ghost/目录下安装的ghost博客(基于nodejs+express),然而不管怎么配置,首页都是显示的是welcome to nginx 我在 /etc/nginx/sites-available/ghost.conf中填写的内容如下:
server { listen 80;
server_name tilear.cn;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127001:2368;
}
}
网站也是按照www.ghostchina.com/install-ghost-on-ali-ecs-forth-step-install-ghost/的教程配置的,然而不知道为啥首页一直是welcome to nginx 安装nginx->mysql->npm的全程无报错,但是在安装ghost的时候(我是安装的ghostchina的英文版ghost), 在最后一步使用forever的时候有提示: root:/srv/ghost# sudo NODE_ENV=production forever start index.js warn: --minUptime not set. Defaulting to: 1000ms warn: --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms info: Forever processing file: index.js 然后参考网上使用forever stop/restart命令: 有报错root:/srv/ghost# sudo NODE_ENV=production forever stop index.js error: Forever cannot find process with id: index.js 请问是跟forever有关吗(或者是nginx配置错了?),谢谢大家了,这几天在网上查了好多资料都没找着解决方法。。。

11 回复
  • 检查nginx配置,确认导入了/etc/nginx/sites-available/下的文件
  • 你是通过tilear.cn访问的吗?根据你的配置只有通过tilear.cn访问才会进入你配置的server
  • 可以看看nginx 的access.log和error.log看看访问了什么文件,或者哪里有错

按照你的藐视应该是forever问题,用forever list (不确定是不是这个命令了)查看Ghost有没有正确跑起来 如果Forever跑不了的话,应该是config.js的问题。具体看看log文件。

nginx部分,确定修改之后用service nginx reload (或类似命令) 重新加载配置文件

@bendise 谢谢回复!我按照您的方式修改了一下,还是welcome to nginx

谢谢各位的回复,然后我试着查看了nginx的access.log;error.log, 其中error.log提示:

2015/11/20 23:02:17 [error] 8204#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 120.195.7.111, server: tilear.cn, request: “GET / HTTP/1.1”, upstream: “http://127.0.0.1:2368/”, host: "www.tilear.cn" root@iZ28t16plksZ:~# sudo cat /etc/nginx/sites-available/nginx.conf cat: /etc/nginx/sites-available/nginx.conf: No such file or directory 配置完全跟着ghostchina.com走,然后参考了@bendise 的部分配置,还是welcome to nginx ,快奔溃了。。。

@hunteryourlove 看这个nginx的error.log说的是/etc/nginx/sites-available/nginx.conf没有找到吧。
应该不是forever的问题,如果nginx代理配置成功而forever启动失败也应该显示的是502啊,你这个是nginx代理没成功吧。
另外,forever 的提示Forever cannot find process with id: index.js是说没有id为index.js的forever的progress在跑,你forever list一下就能看到在跑的id,再把index.js替换成对应的id。

@hunteryourlove LOG 上说明就是Connection refused 连接上级失败,上级的意思就是Forever. 查看下Forever 有没有正常启动先

@lian774739140 他Cat的时候找不到文件,可能只是因为nginx.conf这个文件不存在或者不在这个位置。正常的文件默认是叫做default, 没有.conf结尾应该。

Nginx Log 中明显指出错误是 “connect() failed (111: Connection refused) while connecting to upstream, … , upstream: "http://127.0.0.1:2368/” 也就是说上级的2368端口本来应该运行的forever无法访问… 难道是我理解错了??

@hunteryourlove

@sharking 版本不一样吧,有nginx.conf的,也有default.conf的。不过我觉得你说的对。。。

配置文件出错,查看下是不是nginx加载的配置文件不是你写的那个文件。

配置设好代理文件之后,你需要让Nginx使用你的配置代理文件www,系统默认使用的是
/etc/nginx/sites-enabled/default,
到/etc/nginx/下修改nginx.conf的引用。可以看到

incloud /etc/nginx/sites-enabled/*

这样使用的是default配置文件,你需要将这句修改成:

incloud /etc/nginx/sites-enabled/www

到此已经完成Nginx的配置了。

注意:Nginx的修改是重启后生效的 输入:service nginx restart

看看HTTP头信息,是不是因为缓存,之前遇到过。

回到顶部