警告 failed to open stream permission denied fatal error require_once PHP + NginX + RHEL in VMware

Warning failed to open stream permission denied fatal error require_once PHP + NginX + RHEL in VMware

上下文:在虚拟 php.fpm NginX RHEL 7.3。如果 http://hostname/webcon/index.php 包含普通 html 或简单 php,我可以打开它。但是,当我使用 require_once(我检查了路径)时,出现以下错误。

Warning: require_once(/mnt/data/service/common/dbconfig.php): failed to open stream: Permission denied in /mnt/data/service/webcon/user.php on line 7

Fatal error: require_once(): Failed opening required '/mnt/data/service/common/dbconfig.php' (include_path='.:/usr/share/pear:/usr/share/php') in /mnt/data/service/webcon/user.php on line 7

这是我的 www.conf 在 /php-fpm.d

中的片段
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
;       will be used.
; RPM: apache Choosed to be able to access some dir as httpd
user = apache
; RPM: Keep a group allowed to write in log dir.
group = apache

这是我在 /etc/nginx

中的 nginx.conf 的片段
user  apache;
worker_processes  auto;

error_log  /mnt/data/service/caldav/logs/error.log debug;
pid        /var/run/nginx.pid;

ps-辅助 | grep nginx 显示:

root      43982  0.0  0.0  58756  1064 ?        Ss   15:07   0:00 nginx: master process /usr/sbin/nginx
apache    43983  0.0  0.0  61340  2624 ?        S    15:07   0:00 nginx: worker process
root      44199  0.0  0.0 112648   960 pts/1    S+   15:23   0:00 grep --color=auto nginx

我还为所有 parents/sub-folders 要求分配了 chmod 777。目前所有这些都归 root/root 所有。不知道我还需要做什么。我在谷歌搜索时发现的所有 answers/suggestions 都徒劳无功..

编辑 1:

尝试将 user:group 更改为 www-data。得到下面的错误。

Oct 26 15:32:25 nixs systemd[1]: Starting The PHP FastCGI Process Manager...
Oct 26 15:32:25 nixs php-fpm[44320]: [26-Oct-2017 15:32:25] ERROR: [pool www] cannot get uid for user 'www-data'
Oct 26 15:32:25 nixs php-fpm[44320]: [26-Oct-2017 15:32:25] ERROR: FPM initialization failed
Oct 26 15:32:25 nixs systemd[1]: php-fpm.service: main process exited, code=exited, status=78/n/a
Oct 26 15:32:25 nixs systemd[1]: Failed to start The PHP FastCGI Process Manager.
Oct 26 15:32:25 nixs systemd[1]: Unit php-fpm.service entered failed state.
Oct 26 15:32:25 nixs systemd[1]: php-fpm.service failed.

编辑 2:

编辑 3:

文件权限为 644。目录设置为 755。

你做了 CHMOD 777CHMOD -R 777 ,如果你执行了第一个,我建议你执行第二个。

如果 chmod 不起作用,也许您需要像这样执行 CHOWN 以在您的文件夹和子文件夹中分配用户:CHOWN -R apache:apache /mnt/data/...