这是一个新的安装,其中nginx之前正常启动和停止。我认为这个错误是在启用成功测试(nginx -t)的服务器块后出现的。然后,我尝试重新启动nginx,并收到以下错误:
nginx: [emerg] open() "/usr/share/nginx/on" failed (13: Permission denied)
在尝试重新启动之前,文件"on“不存在。它刚创建,并且是空的。当我重新启动php-fmp (成功),然后尝试重新启动nginx时,错误变为:
nginx: [emerg] open() "/var/run/nginx.pid" failed (13: Permission denied) nginx: configuration file /etc/nginx/nginx.conf test failed
但同样,当我运行nginx -t时,我得到:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful
我认为这可能是一个用户问题,但它是以nginx运行的:
# ps -elf | grep nginx 5 S nginx 2774 2773 0 80 0 - 234152 skb_re 22:07 ? 00:00:00 php-fpm: pool www 5 S nginx 2775 2773 0 80 0 - 234152 skb_re 22:07 ? 00:00:00 php-fpm: pool www 5 S nginx 2776 2773 0 80 0 - 234152 skb_re 22:07 ? 00:00:00 php-fpm: pool www 5 S nginx 2777 2773 0 80 0 - 234152 skb_re 22:07 ? 00:00:00 php-fpm: pool www 5 S nginx 2778 2773 0 80 0 - 234152 skb_re 22:07 ? 00:00:00 php-fpm: pool www 0 R root 2940 2472 0 80 0 - 25811 - 22:18 pts/0 00:00:00 grep nginx
此外,使用sudo nginx -t不会更改任何内容。同样奇怪的是,尽管nginx没有运行,但仍然有一个nginx.pid。删除pid文件只是将错误消息改回为:
nginx: [emerg] open() "/usr/share/nginx/on" failed (13: Permission denied)
删除on文件也没有区别。
发布于 2015-03-22 11:30:04
确保您是以超级用户身份运行的。
sudo nginx -t发布于 2017-07-19 16:11:10
运行getenforce检查SELinux模式。如果显示为强制,则通过运行setenforce 0将模式临时设置为Permissive,然后查看您的应用程序是否正常工作。
发布于 2019-04-26 00:53:19
我也有过类似的问题
nginx: [emerg] open() "/etc/nginx/conf.d/websites.conf" failed (13: Permission denied) in /etc/nginx/nginx.conf:36。
该问题的原因是在特定用户下通过SSH配置配置文件。下面是我修复它的方法(除了chmod/chown之外,我还做了什么)。
如果启用了selinux (在Centos中默认为启用),则
ls -Z /path/to/file 必须将"httpd_sys_content_t“显示为安全上下文。如果你遇到像"user_home_t“这样的东西,你需要用运行来更新它:
chcon -v --type=httpd_sys_content_t /path/to/file 之后,像往常一样重新启动"nginx“或"httpd”。
https://stackoverflow.com/questions/29190522
复制相似问题