title: Warning failed to open stream permission denied fatal error require_once PHP + NginX + RHEL in VMware
body: <p>Context: Set up <strong>NginX</strong> with <strong>php.fpm</strong> on a <strong>virtual</strong> <strong>RHEL 7.3</strong>. I'm able to open <a href="http://hostname/webcon/index.php" rel="nofollow noreferrer">http://hostname/webcon/index.php</a> if it contains plain html or simple php. However, when I use require_once (I've checked the path), I'm getting the below error.  </p>
  
  <pre><code>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
  </code></pre>
  
  <p>Here is the snippet of my www.conf in /php-fpm.d</p>
  
  <pre><code>; 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
  </code></pre>
  
  <p>Here is the snippet of my nginx.conf in /etc/nginx</p>
  
  <pre><code>user  apache;
  worker_processes  auto;
  
  error_log  /mnt/data/service/caldav/logs/error.log debug;
  pid        /var/run/nginx.pid;
  </code></pre>
  
  <p>ps -aux | grep nginx shows:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>I have also assigned chmod 777 to all the parents/sub-folders required. All of them are owned by root/root for now. Not sure what else I need to do. I have tried in vain all the answers/suggestions I've found while Googling.. </p>
  
  <p>Edit 1:</p>
  
  <p>Tried changing user:group to www-data. Get the error below.</p>
  
  <pre><code>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.
  </code></pre>
  
  <p>Edit 2:</p>
  
  <p><a href="https://i.stack.imgur.com/InXZi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/InXZi.png" alt="Screenshot of ls -l dbconfig.php"></a></p>
  
  <p>Edit 3:</p>
  
  <p>File permissions are 644. Directories are set to 755. </p>