[英]Warning failed to open stream permission denied fatal error require_once PHP + NginX + RHEL in VMware
Context: Set up NginX with php.fpm on a virtual RHEL 7.3 . 背景:设置使用nginx的 php.fpm上的虚拟 RHEL 7.3。 I'm able to open http://hostname/webcon/index.php if it contains plain html or simple php. 如果http://hostname/webcon/index.php包含纯HTML或简单php,则可以打开。 However, when I use require_once (I've checked the path), I'm getting the below error. 但是,当我使用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
Here is the snippet of my www.conf in /php-fpm.d 这是我在/php-fpm.d中的www.conf的片段
; 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
Here is the snippet of my nginx.conf in /etc/nginx 这是我在/ 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 -aux | ps -aux | grep nginx shows: 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
I have also assigned chmod 777 to all the parents/sub-folders required. 我还将chmod 777分配给了所需的所有父/子文件夹。 All of them are owned by root/root for now. 目前所有这些都归root / root拥有。 Not sure what else I need to do. 不知道我还需要做什么。 I have tried in vain all the answers/suggestions I've found while Googling.. 我在搜寻Google时发现的所有答案/建议都徒劳无功。
Edit 1: 编辑1:
Tried changing user:group to www-data. 尝试将user:group更改为www-data。 Get the error below. 得到下面的错误。
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.
Edit 2: 编辑2:
Edit 3: 编辑3:
File permissions are 644. Directories are set to 755. 文件权限为644。目录设置为755。
you did CHMOD 777
or CHMOD -R 777
, if youd have executed the first one I suggest you to do the second one. 如果您已执行第一个,则您执行过CHMOD 777
或CHMOD -R 777
,我建议您执行第二个。
If chmod is not working, maybe you need to do a CHOWN to assign the user in your your folder and subfolder like this : CHOWN -R apache:apache /mnt/data/...
如果chmod不起作用,也许您需要执行CHOWN来在您的文件夹和子文件夹中分配用户,如下所示: CHOWN -R apache:apache /mnt/data/...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.