nginx已经启动但未监听80端口。

3

我有一个Ubuntu服务器14.04 VPS,目前正在使用apache2提供静态网站服务。我正在切换到nginx来提供几个nodejs站点的服务。

我安装了nginx。

$ nginx -v
nginx version: nginx/1.4.6 (Ubuntu)

我正在使用默认配置

$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

我确认Apache2未运行,导致问题出现。

$ sudo service apache2 status
 * apache2 is not running

我启动 Nginx 并确认其状态。

$ sudo service nginx status
 * nginx is running

但是即使运行sudo netstat -natpsudo fuser 80/tcp也没有任何输出。

我已经在/etc/nginx/sites-available/mydomain.tld中配置了我的站点,然后将其链接到sites-enabled文件夹。

仍然没有任何输出。

1个回答

3
在撰写问题并重现步骤的过程中,我找到了问题所在。
我已经创建并编辑了位于/etc/nginx/sites-available/mysite.tld的我的站点服务器。
然后,为了启用该站点,我在目录/etc/nginx/中运行了ln -s sites-available/mysite.tld sites-enabled/mysite.tld,将其链接到sites-enabled文件夹中。
直到今天早上,当我无法vim进入sites-enabled链接版本时,我才意识到我创建了一个错误的链接。
通过对错误链接进行rm,然后使用整个内容的绝对路径ln -s /etc/nginx/sites-available/mysite.tld /etc/nginx/sites-enabled/mysite.tld,随后重新启动nginx,现在可以正常监听端口80。
简而言之,有时候最好就是上床睡觉,在早上再看一遍。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接