I have jdk1.7.0_07 installed on server(linux). The file permission to ~/bin files are executable(755). However when I tried to execute,
$output = exec("/usr/java/jdk1.7.0_07/bin/java -version 2>&1");
echo $output;
It gives permission denied error, I have tried this,
$output = exec("java -version 2>&1");
echo $output;
Which gives command not found error. While checking my environment variables. I have succesfully added JAVA_HOME = /usr/java/jdk1.7.0_07 and for PATH = /usr/java/jdk1.7.0_07/bin
When I run above mentioned PHP script it keeps giving me those permission denied or command not found error. Any personal experience or clue?
If you are running these commands from the command-line, you probably execute them with your own user permissions. However, when you execute these same commands via a PHP script in a web app, they will be executed with the Apach user (typically www-data) permissions. These means that you cannot rely on the command-line output to debug permission errors unless you can log in as the exact same user that runs your PHP script.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With