部署好nginx服务器后,输入IP地址和端口号,出现403 Forbiddent界面。
可以查看nginx错误日志,有看到如下信息
directory index of "/data/" is forbidden, client:
查看nginx配置文件,发现默认的location指定的root路径,我这里是
location / {
root /data/;
index index.html index.htm;
}
把 root的 /data/ 修改成html
即
location / {
root html;
index index.html index.htm;
}
重加载nginx,可以看到nginx启动成功界面
再记录nginx启动失败原因:
[emerg] 5580#3332: bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket in a way forbidden by its access permissions)
[emerg] 7552#7556: bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket in a way forbidden by its access permissions)
错误原因是绑定80端口错误,说明80端口被占用,nginx绑定失败。
解决办法
1、kill掉占用80端口的程序,再次启动nginx
2、若占用80端口的服务/程序不能关闭,则更改nginx监听的端口号