启动报错:
nginx: [warn] the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /usr/local/nginx/conf/nginx.conf:2
nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)
上面这是两个错,
第一个需要将nginx配置文件里面的:user username;这行去掉
第二个使用setcap命令添加权限:
使用sudo权限,为NGINX二进制文件添加CAP_NET_BIND_SERVICE
权限,使其能够绑定低端口(如80端口):sudo setcap 'cap_net_bind_service=+eip' /usr/sbin/nginx
/usr/sbin/nginx为自己编译后的nginx路径
第二步完成后nginx脚本就变成红色的了,然后执行启动命令就好了。