首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Nginx 6.6 CentOS 1.6.2 -突然无法重启nginx - nginx:[emerg] open()“/usr/share/nginx/on”失败(13:权限被拒绝)

Nginx 6.6 CentOS 1.6.2 -突然无法重启nginx - nginx:[emerg] open()“/usr/share/nginx/on”失败(13:权限被拒绝)
EN

Stack Overflow用户
提问于 2015-03-22 11:09:57
回答 3查看 5.5K关注 0票数 3

这是一个新的安装,其中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文件也没有区别。

EN

回答 3

Stack Overflow用户

发布于 2015-03-22 11:30:04

确保您是以超级用户身份运行的。

代码语言:javascript
运行
复制
sudo nginx -t
票数 4
EN

Stack Overflow用户

发布于 2017-07-19 16:11:10

运行getenforce检查SELinux模式。如果显示为强制,则通过运行setenforce 0将模式临时设置为Permissive,然后查看您的应用程序是否正常工作。

票数 0
EN

Stack Overflow用户

发布于 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中默认为启用),则

代码语言:javascript
运行
复制
ls -Z /path/to/file 

必须将"httpd_sys_content_t“显示为安全上下文。如果你遇到像"user_home_t“这样的东西,你需要用运行来更新它:

代码语言:javascript
运行
复制
chcon -v --type=httpd_sys_content_t /path/to/file 

之后,像往常一样重新启动"nginx“或"httpd”。

参考https://wiki.centos.org/HowTos/SELinux

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29190522

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档