LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Apache, PHP, and JAVA_HOME on the command line. (https://www.linuxquestions.org/questions/linux-server-73/apache-php-and-java_home-on-the-command-line-614503/)

neocookie 01-18-2008 06:33 AM

Apache, PHP, and JAVA_HOME on the command line.
 
I've got a really odd problem that I can't seem to google my way through.

We have a PHP app running under apache which executes a java prog on the command line and sends back the result. Its not rocket science, and it was all working fine under lighttpd (which seems to run as the root user by default).

Turns out, when apache is running, PHP scripts are ran under the "apache" user. Echo'ing the PATH I can see that JAVA_HOME isn't set. So, using the following script:

<?php
system('whoami');
echo "\n";
system('echo $PATH');
?>

I get the following result:

apache
/usr/local/bin:/bin:/usr/bin

So, I've set JAVA_HOME and appended it to the PATH variable in: /etc/profile, /etc/bashrc, /etc/profile.d/java.sh

No dice.

I've also changed the user apache runs as to a new user, "www", and set up the env vars in ~/.bashrc

Still no dice.

Checking the above script, I see that the running user has changed, but the path is still the same.

Anyone able to point me in the right direction?

senramesh 01-18-2008 07:31 AM

Hi!

Why dont you give the absolute path something like '/usr/local/jdk1.4/bin/java' for using within the PHP. You can set the -classpath option for the using the user defined classes.

May be you can give a try........


All times are GMT -5. The time now is 07:27 AM.