Running CentOS 7 with apache 2.4, using PHP5.6 from REMI repository. My wordpress and phpmyadmin seem to work, however any page that has phpinfo() causes a permission denied entry into my error log.

Digging around the best I could find that may hint to something was along the lines of, if a symlink is being referenced, the permission changes from chown and chmod, may not be fully applied correctly without special parameters. Not exactly sure, but the error log doesnt seem to mention paths that are symlinks.

The message from the error log is below:

PHP Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0 PHP Fatal error: Unknown: Failed opening required '/var/www/html/phpinfo2.php' (include_path='.:/usr/share/pear:/usr/share/php') in Unknown on line 0

Apache is running as "apache" user. The php file, /usr/share/pear, and /usr/share/php have read/write/execute permissions for the owner (apache)

I am pretty new to linux, but I can try to obtain any info needed to help sort this out. This is currently a lab virtual machine that I have complete control over. Any help would be greatly appreciated!

EDIT running ps axZ seems to show what httpd is running under: system_u:system_r:httpd_t:s0 3664 ? S 0:00 /usr/sbin/httpd -DFOREGROUND

i then compared what security contexts the /var/www/html files had to the directories mentioned in the error log. Those security contexts were: unconfined_u:object_r:httpd_sys_content_t:s0

So i used chcon to set the user and type contexts to match those of the published website directory. I still get the same error. I would rather not turn off SELinux as I am trying to get into the habit of keeping it on. However, disabling it does let the phpinfo() function load.

Any SELinux ideas?

  • Is SELinux running? – duenni Feb 16 '15 at 14:17
  • yes. running ls -laZ on both of the include paths mentioned in the error log outputs entries similar to: drwxr-xr-x. apache root system_u:object_r:usr_t:s0 . – DontStealMyFish Feb 16 '15 at 18:00
  • You should look at the security context on the specific file that isn't loading. – Michael Hampton Feb 17 '15 at 3:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.