The exec command doesn’t work on my server, it does not do anything, I’ve had safe_mode off, and verified that all the console commands are working, I’ve tried with absolute paths. I’ve checked the permissions on the applications and all the applications I need have execution permissions. I don’t know what else to do, here are the rundown of the codes I’ve tried.
echo exec('/usr/bin/whoami');
echo exec('whoami');
exec('whoami 2>&1',$output,$return_val);
if($return_val !== 0) {
echo 'Error<br>';
print_r($output);
}
exec('/usr/bin/whoami 2>&1',$output,$return_val);
if($return_val !== 0) {
echo 'Error<br>';
print_r($output);
}
The last two codes display:
Error
Array ( )
I’ve contacted the server service and they can’t help me, they don’t know why the exec command isn’t working.
have a look at
/etc/php.ini, there under:make sure that exec is not listed like this:
If so, remove it and restart the apache.
For easy debugging I usually like to execute the php file manually (Can request more errors without setting it in the main ini). to do so add the header:
to the beginning of the file, give it permissions using
chmod +x myscript.phpand execute it./myscript.php. It’s very heedful especially on a busy server that write a lot to the log file.EDIT
Sounds like a permissions issue. Create a bash script that does something simple as
echo "helo world"and try to run it. Make sure you have permissions for the file and for the folder containing the file. you chould just dochmod 755just for testing.