Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Apache2, PHP5 and environment variables



i think you are looking for

http://httpd.apache.org/docs/2.0/mod/mod_env.html



On Wed, Apr 16, 2008 at 9:58 AM, Burt Crépeault <email@hidden> wrote:
Hi all,

I'm using the exec() command in PHP5 to run some Perl scripts external to my web application. I noticed that the environment variables are not always set properly in the shell created by exec(). For example, if I run the following PHP script through apache just to list the content of environment variables, I get these results:

<?php
exec("export", $output);
print "<pre>";
var_dump($output);
print "</pre>";
?>

array(4) {
[0]=>
string(13) "export OLDPWD"
[1]=>
string(43) "export PATH="/usr/bin:/bin:/usr/sbin:/sbin""
[2]=>
string(41) "export PWD="/Library/WebServer/Documents""
[3]=>
string(16) "export SHLVL="1""
}
Some critical environment variables are missing such as TMPDIR and PERL5LIB and so on. I found a workaround, namely using the putenv() command at the beginning of my script, like this:

putenv("PATH={$_ENV["PATH"]}:$dir1:$dir2");
putenv("PERL5LIB=$dir3:$dir4");
putenv("TMPDIR=/private/tmp");


However, I'd like to set these variables once and for all in a profile somewhere and not have to deal with them in the script itself.

So my question is: where is that profile for the _www user (or any user running under apache)?

--
Burt Crépeault
Research Assistant
Centre de Recherche de l'Université Laval - Robert-Giffard
Québec, Canada

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Web-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/web-dev/email@hidden

This email sent to email@hidden

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Web-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/web-dev/email@hidden

This email sent to email@hidden

References: 
 >Apache2, PHP5 and environment variables (From: "Burt Crépeault" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.