Centos7 nginx提示错误 Access denied.?

Posted 时光不改

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Centos7 nginx提示错误 Access denied.?相关的知识,希望对你有一定的参考价值。

 

SELinux will cause this error on CentOS/RHEL 7+ by default :(

CentOS/RHEL 7+ 系统默认会因为SELinux出现这个报错

 

To test if SELinux is the source of your woes, do

你可以通过下面这个命令关闭SELinux,进行测试

setenforce 0

 

... and see if everything works. If that fixed it, you can leave SELinux off (weak, you‘re better than that), or you can turn it back on with

看看是否运行正常,如果成功修复了,你可以修改配置文件永久保留关闭,或者再打开SELinux

setenforce 1

 

... and then properly fix the issue.

然后妥善解决这个问题。

 

If you do

如果你执行

tail -f /var/log/audit/audit.log

 

... you‘ll see the SELinux issue. In my case, it was denying php-FPM access to web files. You can run the following directives to fix it:

你将会看到是SELinux的问题。在我看来,这是因为SELinux拒绝了PHP-FPM访问Web文件。您可以运行以下指令来修复它:

setsebool -P httpd_can_network_connect_db 1
setsebool -P httpd_can_network_connect 1

 

This actually didn‘t fix it for me at first, but then restoring SELinux context did it

这一步还没有完全修复好,继续执行下面命令修复上下文

restorecon -R -v /var/www(你的web目录)

 

Hope that helps.

希望能帮到你

 

作者:匿名用户

链接:https://www.zhihu.com/question/22128267/answer/105600681

来源:知乎

著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

以上是关于Centos7 nginx提示错误 Access denied.?的主要内容,如果未能解决你的问题,请参考以下文章

Nginx 提示10013: An attempt was made to access a socket in a way forbidden by its access permissions

FlashFXP连接linux服务器(centos7环境)提示连接失败 (Unable to access SFTP sub-system, operation failed.)

Nginx——nginx的访问控制详解一(Centos7通过yum方式安装)

Nginx——nginx日志类型(Centos7通过yum方式安装)

Nginx遇上Access Denied提示怎么解决

phpMyAdmin 502 网关错误 [CentOS7, nginx]