Google Answers Logo
View Question
 
Q: php: shell_exec not working ( No Answer,   3 Comments )
Question  
Subject: php: shell_exec not working
Category: Computers > Programming
Asked by: qtluong-ga
List Price: $5.00
Posted: 07 Mar 2006 19:24 PST
Expires: 06 Apr 2006 20:24 PDT
Question ID: 704767
I am trying to make system calls in php using shell_exec on my
(dedicated) server. Running php 4.3.9 under Redhat EL 4.
It works OK with unix-native commands such as 'ls' or with commands
that I place in the /bin directory. However, if I place a command in
another directory, and call it by full path with shell_exec, nothing
happens. I don't think it is a permission problem, since I can log on
the shell as a different user, and execute the command OK. On the
other hand, I am experiencing this problem only on this particular
server. I have access to two other unix boxes, and none exhibit this
problem, so I am inclined to think there is a configuration problem.
Any ideas ?
Answer  
There is no answer at this time.

Comments  
Subject: Re: php: shell_exec not working
From: chris_pmf-ga on 10 Mar 2006 03:27 PST
 
I think on this server is open_basedir or safe_mode enabled.

Try to add this line above your shell_exec line:

error_reporting(E_ALL);
Subject: Re: php: shell_exec not working
From: rssohan-ga on 10 Mar 2006 18:19 PST
 
It seems most probably a permission problem.  If I were you I would
check the permissions on the bin directory and the files in it.  PHP
will probably run under the uid of the webserver, which, on most
systems is either "apache" or "nobody" depending on the configuration.
Subject: Re: php: shell_exec not working
From: happydrgn-ga on 12 Mar 2006 21:53 PST
 
It could be a limitation on Apache by SELinux, you can try disabling it to test by:

Opening system-config-securitylevel in X
Disable SELinux protection for Apache, from the SeLinux settings
and restart apache, service httpd restart

SELinux errors also show up in /var/log/messages, you can try a tail
-0f /var/log/messages while running your PHP script to look for
errors.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy