nginx 不侦听端口 80 [英] nginx not listening to port 80

查看:72
本文介绍了nginx 不侦听端口 80的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚安装了 Ubuntu 12.04 服务器和 nginx 1.2.7,从启用了站点的站点中删除了 default 并将我自己的文件添加到 sites-available 和符号链接中启用网站.然后重启nginx.

I've just installed a Ubuntu 12.04 server and nginx 1.2.7, removed default from sites-enabled and added my own file into sites-available and symlink at sites-enabled. Then restarted nginx.

问题:但是转到 URL 不会加载站点.netstat -nlp |grep nginxnetstat -nlp |grep 80 都没有返回结果!lsof -i :80 也不返回任何内容.来自另一台服务器的 dig 返回正确的 IP 地址,因此它不应该是 DNS 问题.我能够连接到 apache,我现在已经停止了它的服务.nginx 日志也没有显示.

Problem: However going to the URL does not load the site. netstat -nlp | grep nginx and netstat -nlp | grep 80 both returns no results! lsof -i :80 also returns nothing. A dig from another server returns the correct ip address so it shouldn't be a DNS problem. I was able to connect to apache which I have now stopped its service. nginx logs also show nothing.

我应该如何解决这个问题?

How should I troubleshoot this problem?

/etc/nginx/site-available/mysite.com

server {
    listen   80;
    server_name www.mysite.com mysite.com *.mysite.com;
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;
    root /var/www/mysite/public;

    index index.php index.html;

    location / {
        try_files $uri $uri/ /index.php?$args ;
    }
    location ~ .php$ {
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_read_timeout 300;
    }

}

推荐答案

我遇到了同样的问题,解决方案是我没有正确地符号链接我的 siteconf 文件.尝试运行 vim/etc/nginx/sites-enabled/mysite.com——你能做到吗?我收到权限被拒绝".

I had this same problem, the solution was that I had not symlinked my siteconf file correctly. Try running vim /etc/nginx/sites-enabled/mysite.com—can you get to it? I was getting "Permission Denied."

如果没有运行:

rm /etc/nginx/sites-enabled/mysite.com
ln -s /etc/nginx/sites-available/mysite.com /etc/nginx/sites-enabled/mysite.com

这篇关于nginx 不侦听端口 80的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆