LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 01-18-2008, 06:33 AM   #1
neocookie
Member
 
Registered: Apr 2004
Location: Leeds, UK
Distribution: FC1, FC2, Debian
Posts: 308

Rep: Reputation: 30
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?
 
Old 01-18-2008, 07:31 AM   #2
senramesh
LQ Newbie
 
Registered: May 2007
Posts: 21

Rep: Reputation: 15
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........
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache PHP != Command Line PHP? wh33t Linux - Server 3 10-23-2007 09:21 PM
PHP from command line prabhatsoni Linux - Software 0 08-16-2007 11:37 AM
PHP on the command line? kev000 Linux - General 4 11-28-2006 03:16 PM
[php] accessing command line dtra Linux - Software 1 04-26-2005 07:19 PM
php from command line odious1 Linux - Software 4 05-03-2004 12:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration