问下为啥我的php会Access denied.,我php进程是www的,nginx也是www,文件用户也是www的
情况是这样的我安装了nginx,php7.4,用remi安装的
然后我配置了nginx user www;
配置的listen 是127.0.0.1:9000;
nginx 对php转发
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
然后我配置php-fpm.conf user 也是www,
然后我ps -ef |grep php
root 19146 1 0 12:05 ? 00:00:00 php-fpm: master process (/etc/opt/remi/php74/php-fpm.conf)
www 19147 19146 0 12:05 ? 00:00:00 php-fpm: pool www
www 19148 19146 0 12:05 ? 00:00:00 php-fpm: pool www
www 19149 19146 0 12:05 ? 00:00:00 php-fpm: pool www
www 19150 19146 0 12:05 ? 00:00:00 php-fpm: pool www
www 19151 19146 0 12:05 ? 00:00:00 php-fpm: pool www
www 19152 19146 0 12:05 ? 00:00:00 php-fpm: pool www
然后我ps -ef |grep nginx
root 17416 1 0 11:45 ? 00:00:00 nginx: master process nginx -c /etc/nginx/nginx.conf
www 18489 17416 0 11:58 ? 00:00:00 nginx: worker process
www 18490 17416 0 11:58 ? 00:00:00 nginx: worker process
www 18491 17416 0 11:58 ? 00:00:00 nginx: worker process
www 18492 17416 0 11:58 ? 00:00:00 nginx: worker process
www 18493 17416 0 11:58 ? 00:00:00 nginx: worker process
www 18494 17416 0 11:58 ? 00:00:00 nginx: worker process
我代码也是www用户的,不知为啥给我报Access denied.错误
nginx报这个错误,18500#18500: *61 FastCGI sent in stderr: "PHP message: PHP Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0Unable to open primary script: /home/www/test/public/index.php (Permission denied)" while reading response header from upstream, client: 127.0.0.1, server: , request: "GET /device/admin/uploadData HTTP/1.0", upstream: "fastcgi://127.0.0.1:9000", host: "10.23.23.12"
我后来搜了下,看到这个博客blog.csdn.net/weixin_34075268/arti... ,解决了我的问题,用的SELinux状态(Yes)将selinux关闭即可