php can't execute any external command?
We moved from Slackware to CentOS here, it 开发者_如何学Pythonwas 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
- disable_functions in php.ini 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
SELinux is blocking your attempts to run them. I recommend you come up with rules that allow you to run the subset of external commands required and load that as a module.
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.
Does PHP run as Apache on the server? I thought it ran as Nobody..
https://serverfault.com/questions/207989/php-cant-execute-any-external-command/208001#208001
Generally PHP on centOS is ran as nobody unless you have compiled php as fastcgi, dso etc...
精彩评论