新手问题 [已解决] 配置 Nginx,一直显示 Welcome to nginx on EPEL!

killpigman · 2016年02月22日 · 最后由 huobazi 回复于 2016年02月23日 · 9659 次阅读
#user  nobody;
worker_processes  1;
events {
    worker_connections  1024;
}
http {
    passenger_root /usr/local/rvm/gems/ruby-2.2.1/gems/passenger-5.0.25;
    passenger_ruby /usr/local/rvm/gems/ruby-2.2.1/wrappers/ruby;
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen 80;
        server_name 139.129.26.234;
        root /home/blog/public;
        passenger_enabled on;
        rails_env development;
  }
}

重启 nginx 了吗?

#1 楼 @huobazi 重启了,并没有什么变化,也没报错。

#2 楼 @killpigman 你现在编辑的这个 nginx.conf 文件在哪?

#3 楼 @huobazi vim /opt/nginx/conf/nginx.conf 在 conf 目录下面还有一个 nginx.conf.default

5 楼 已删除

#4 楼 @killpigman 你现在生效的是下面这个,估计你有多个版本的 nginx 同时存在。

You should now put your content in a location of your choice and edit the root configuration directive in the nginx configuration file /etc/nginx/nginx.conf.

#6 楼 @huobazi 多谢多谢,果然是这个问题。 现在我全部卸载,重装了 nginx。 但是在 nginx -s reload 时,会报

nginx: [error] invalid PID number "" in "/usr/local/nginx/logs/nginx.pid"

按照网上的解决方案:

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

会输出:

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()

但是并没有效果。

#6 楼 @huobazi 解决了,端口被占用了,谢谢。

#6 楼 @huobazi 请问是怎样看是哪个 nginx.conf 生效? 这段话哪来的

You should now put your content in a location of your choice and edit the root configuration directive in the nginx configuration file /etc/nginx/nginx.conf.
需要 登录 后方可回复, 如果你还没有账号请 注册新账号