Centos上的nginx php-fpm“访问被拒绝”

前端之家收集整理的这篇文章主要介绍了Centos上的nginx php-fpm“访问被拒绝” 前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我在index.PHP文件上得到“访问被拒绝”.我通过在服务器上使用touch命令创建了test.PHP,它正在运行.

我通过使用touch命令和c / p index.PHP源新的index.PHP文件删除了index.PHP并创建了index.PHP,然后检查error.log现在该问题发生在另一个PHP文件中.

一切正常,今天这个问题开始了.此配置也可以正常工作,没有任何更改,并且发生了此问题.

这是我的配置文件.

/etc/Nginx/conf.d/default.conf:

server {

    listen 80;
    server_name X.X.X.X;
    root /var/www/domain.com;
    index index.PHP;

    location / {
        try_files $uri $uri/ /index.PHP$is_args$args;
    }

    location ~ \.PHP${
        try_files $uri /index.PHP =404;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_split_path_info ^(.+\.PHP)(/.+)$;
        fastcgi_index index.PHP;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    error_page 404 /404.html;

    location = /404.html {
        root /var/www/domain.com;
    }

    error_page 500 502 503 504 /50x.html;

    location = /50x.html {
        root /var/www/domain.com;
    }

}

/var/www/domain.com/:

drwxr-xr-x.  8 Nginx Nginx  4096 Nov 16 16:39 .
drwxr-xr-x.  5 Nginx Nginx  4096 Oct 30 20:47 ..
-rwxr-xr-x.  1 Nginx Nginx   146 Jun  1 18:16 CONTRIBUTING.md
drwxr-xr-x. 12 Nginx Nginx  4096 Oct 30 23:36 app
-rwxr-xr-x.  1 Nginx Nginx  2452 Jun  1 18:16 artisan
drwxr-xr-x.  2 Nginx Nginx  4096 Oct 30 23:36 assets
drwxr-xr-x.  2 Nginx Nginx  4096 Oct 30 23:36 bootstrap
-rwxr-xr-x.  1 Nginx Nginx   697 Jun  1 18:16 composer.json
-rwxr-xr-x.  1 Nginx Nginx 58540 Oct  1 00:19 composer.lock
-rwxr-xr-x.  1 Nginx Nginx     0 Jun  1 18:16 favicon.ico
-rwxr-xr-x.  1 Nginx Nginx  1580 Oct 31 00:05 index.PHP
drwxr-xr-x.  2 Nginx Nginx  4096 Oct 30 23:36 packages
-rwxr-xr-x.  1 Nginx Nginx   567 Jun  1 18:16 PHPunit.xml
drwxr-xr-x.  2 Nginx Nginx  4096 Oct 30 23:55 public
-rwxr-xr-x.  1 Nginx Nginx  2051 Jun  1 18:16 readme.md
-rwxr-xr-x.  1 Nginx Nginx    24 Jun  1 18:16 robots.txt
-rwxr-xr-x.  1 Nginx Nginx   519 Jun  1 18:16 server.PHP
-rwxr-xr-x.  1 Nginx Nginx    41 Nov 16 16:39 test.PHP
drwxr-xr-x. 20 Nginx Nginx  4096 Oct 30 23:36 vendor

/etc/Nginx/Nginx.conf:

user              Nginx;

/etc/PHP-fpm.d/www.conf:
    用户= Nginx
    组= Nginx

/var/log/Nginx/error.log:

Unable to open primary script: /var/www/domain.com/index.PHP (Permission denied)" while reading response header from upstream,client: *,server: *,request: "GET / HTTP/1.1",upstream: "fastcgi://127.0.0.1:9000",host: "*"
2014/11/16 18:27:54 [error] 5070#0: *21 FastCGI sent in stderr: "PHP message: PHP Warning:  Unknown: Failed to open stream: Permission denied in Unknown on line 0

删除index.PHP并使用touch命令创建相同文件后:

PHP message: PHP Fatal error:  require(): Failed opening required '/var/www/domain.com/bootstrap/autoload.PHP'
最佳答案
我在同一问题上花了整整一天的时间,最终发现selinux是造成此问题的原因.

我没有确切搜索哪个设置可能有问题,只是禁用了整个设置(SELINUX =在/ etc / selinux / config中禁用并重新启动),最后PHP-fpm可以正常工作.

原文链接:https://www.f2er.com/nginx/532259.html

猜你在找的Nginx相关文章