Andre Garzia
Andre Garzia

Reputation: 983

php can't execute any external command?

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 version 5.3.3 and CentOS 5.5

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

Upvotes: 1

Views: 3352

Answers (4)

Andre Garzia
Andre Garzia

Reputation: 983

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.

Upvotes: 1

Glenn Kelley
Glenn Kelley

Reputation: 1

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...

Upvotes: 0

Brian H
Brian H

Reputation: 833

Does PHP run as Apache on the server? I thought it ran as Nobody..

Upvotes: 0

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799390

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.

Upvotes: 3

Related Questions