Apache Server configuration support - Setting an environment variable

This is Interesting: Free IT Magazines  
Home > Archive > Apache Server configuration support > August 2007 > Setting an environment variable





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Setting an environment variable
lskatz

2007-08-15, 1:24 pm

Hi,
I want to run a program under php/apache that requires me to set an
environment variable. I also need to add the program's directory to
the PATH variable. In bash in my own profile, I needed to add the
following to get it to work correctly:

PATH=$PATH:$HOME/bin:/usr/local/bin/phd2fasta
export PATH

lskatz

2007-08-15, 1:24 pm

Hi (sorry, my previous message was sent before I finished),
I want to run a program under php/apache that requires me to set an
environment variable. I also need to add the program's directory to
the PATH variable. In bash in my own profile, I needed to add the
following to get it to work correctly:

PATH=$PATH:/usr/local/bin/phd2fasta:/usr/local/bin/phred
export PATH
export PHRED_PARAMETER_FILE=/usr/local/bin/phred/phredpar.dat

How can I give the apache user these variables? I have already tried
by puting them in apachectl and restarting apache, but nothing
changed. I have also tried by using the php command setenv and the
php variable $_SERVER with no results.

Thank you for your help.

lskatz

2007-08-16, 7:27 pm

I made a php test file that may or may not help. In it, I try to run
a program called "phred" that requires a bash variable called
PHRED_PARAMETER_FILE. The other program, phrap, does not require a
bash variable.
I ran it from the command line by typing in "php index.php" and it ran
without error. However, when the web site executes it, it gets an
error.
This leads me to believe that apache cannot set shell or bash
variables.... why?? How can it be fixed?


THE CODE
<?
print "<pre>";
$command="PHRED_PARAMETER_FILE=/usr/local/bin/phred/phredpar.dat";
testCommand($command);

$command="echo : \$PHRED_PARAMETER_FILE :";
testCommand($command,true);

$command="./phred *.ab1 -s -q -p";
testCommand($command);

$command="/usr/local/bin/phred/phred *.ab1 -s -q -p";
testCommand($command);

$command="/usr/local/bin/phrap/phrap temp.seq";
testCommand($command);

testCommand('ls -l');

// executes a command with an exit code, with the option of displaying
the std output
function testCommand($command,$display=false){
print "\n$command ";
exec($command,$stdout,$exit_code);
if($display) print join("\n",$stdout);
print " ==> $exit_code\n";
}
?>

WEB SITE OUTPUT
PHRED_PARAMETER_FILE=/usr/local/bin/phred/phredpar.dat ==> 0

echo : $PHRED_PARAMETER_FILE : : : ==> 0

../phred *.ab1 -s -q -p ==> 255

/usr/local/bin/phred/phred *.ab1 -s -q -p ==> 255

/usr/local/bin/phrap/phrap temp.seq ==> 0

ls -l ==> 0

lskatz

2007-08-20, 7:26 pm

No one has anything...?

Davide Bianchi

2007-08-21, 7:23 am

On 2007-08-20, lskatz <lskatz@gmail.com> wrote:
> No one has anything...?


this is apache.configuration, you'd better off in some php related
group.

Davide

--
To me it sounds like a flock of ducks trying to out-honk a Mac Truck, but
getting cut short tragically as they all fly into the grill work of the truck.
But that's just me.
-- Paul Tomblin, about the system beep on the Alpha UDB
lskatz

2007-08-21, 1:22 pm

> this is apache.configuration, you'd better off in some php related
> group.


This is totally apache related.
I need to set an environment variable (PHRED_PARAMETER_FILE) for the
apache user. The php is there only to show information.

lskatz

2007-08-24, 7:19 pm

Just in case anyone who is doing the exact same thing as me is
looking, this is what I did. In the end, the right solution was not
to edit the environment variables but it was to edit the readEnvVar.c
file in the phred directory to this (changing around the phredpar.dat
path), and then running make again:

#ifdef ANSI_C
int readEnvVar( Option *option )
#else
int readEnvVar( option )
Option *option;
#endif
{
pstrcpy( option->parFileName,
"/......../phredpar.dat", PHRED_PATH_MAX );
return( OK );

}

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2009 webservertalk.com