How to get the output of java apps in a php web script?
I have written a Java application that runs from the command line. I want to allow users to access this via a simple PHP web interface - it'll just allow them to specify certain parameters, and then execute the java app and return the output.
For some reason, I'm getting a 'Permission Denied' error message when I try to do anything with Java, even something as simple as:
shell_exec('/usr/bin/java -version 2>&1');
returns 'sh: /开发者_如何学JAVAusr/bin/java: Permission denied ' when run through a browser.
If I give apache a shell account and log in as apache, I can execute this command fine.
Is there some kind of setting preventing the JVM running if there is no associated tty? How can I get this to work? I'm running PHP 5.3.2.
Thanks
Your application host may be confined with a tool like AppArmor or SELinux or TOMOYO or SMACK, or similar confinement tools.
It would be very simple to confine an Apache to allow executing /usr/bin/whoami
but not /usr/bin/java
.
Ask your system administrator to grant access to java and your jars for you.
精彩评论