配置host内容为:

正常的话输入www.littlenannan.com和localhost应该会出现Nginx的页面,可是我却无法访问,因为启动nginx.exe的时候出现了如下的错误:

在网上搜了一下,按照查找到的解决方法试了试。
解决方法1(来自nginx bind() to 0.0.0.0:80 failed):
进入conf路径下:

打开nginx.conf文件:

监听端口原先为80,我们将它改为8088:

OK,保存,重新启动,我们看到任务管理器中已经有nginx.exe啦(不知道为虾米有两个):

虽然nginx可以启动了,但是依然访问不了nginx的页面,解决方法1失败。
解决方法2(来自Win7下,nginx默认80端口被System占用,造成nginx启动报错):
在cmd窗口运行命令:C:\nginx-1.10.2>netstat -aon | findstr ":80"。

看到80端口果真被占用,发现占用的pid是4,名字是System。怎么禁用呢?
1、打开注册表:regedit
2、找到:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\HTTP
3、找到一个REG_DWORD类型的项Start,将其改为0

4、重启系统。
Emmm...还是失败了。
解决方法3(来自:Windows10下启动nginx反向代理服务器失败的解决方法(重在解决:80端口被PID为4的System占用问题)):
键入命令查看http服务状态:


我们看到进程ID为2160,到任务管理器中遭到ID为2160的服务:

发现是SqlServer数据库(在网上看了一下,占用80端口的情况有这几个可能:System、IIS服务器、SqlServer数据库),我们把这个服务停掉。
啊啊啊啊我要哭了〒▽〒终于成功了,这个页面!(注意是http://localhost,前面是http,不是ftp哦)

再用www.littlenannan.com域名试:

耶!开心得转圈圈!

虽然是很简单的问题,可是在网上搜了很久,试了好多方法。虽然问题一样,可是每个人、每台电脑的情况不一样,要具体问题具体分析,只要有肯探索的精神,什么问题都可以解决哒!
2019/04/18 早上 更新
今天启动Nginx又出现了这个问题:

查到了解决方法:nginx:[emerg] could not build server_name_hash
打开nginx.conf文件。

添加如下配置即可:

然后再启动nginx,又会发生之前的问题,用上文的方法解决就好啦。
2019/04/18 晚上21:41 更新
又出新的问题了:

在网上查找了好半天问题,发现是新配置了一个文件s.happymmall.com.conf中有这样一句:

OK,把它注释掉即可。
然后陷入老问题,端口被占用,按照前文方法解决就OK。(哭哭,问题好多呀)
网友评论