Centos – php can’t execute any external command

centosexecPHP

We moved from Slackware to CentOS here, it was working fine then without notice, php stopped executing external calls such as calls to "wc" and "spamc". All such calls appear on error_log as:

sh: /usr/bin/spamc: Permission denied

The paths are correct. We have the permissions set correctly and apache is supposed to be able to execute the files with no problem. We're NOT on safe_mode and we do not have base_dir set. It is not SELinux, or at least sestatus says SELinux is disabled.

summary:

  • PHP can't execute anything thru exec() or popen()
  • Paths to binaries are correct.
  • We are not in safe mode
  • We don't have base_dir set
  • Permissions on the binaries allow apache user to execute them
  • SELinux is disabled
  • on php.ini the disable_functions is empty
  • We have no clue why it doesn't work

PHP version 5.3.3 and CentOS 5.5

Anyone has a clue of what might be happening?
Thanks in advance

Best Answer

Found the error.

I was trying to execute /usr/bin/tidy for example, the usr folder had a 644 permission which is akin to lovecraftian horror in my book. I could work because I was root.

I figured it out after going crazy and deciding to check the permissions on all the path components of the command from the root / folder to the tidy binary, I found all permissions set correctly but the usr folder perms were completely screwed.

This is fixed.

Related Topic