setting up virtualmin run environment

hello all -

i am sorta brain dead today (well OK more than usual)

i have a php script that runs fine from the command line, but throws a temper-tantrum when ran from the website.

when i run at the command line, i have this in my .bash_profile file:

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/ ;
export LIBPATH=/usr/local/lib/ ;
export LD_LIBRARY_PATH=/usr/local/lib/ ;

how can i make sure the same commands are included when php runs from the website? i tried .bashrc but that didnt do it, nor did .login.

any help is appreciated.

Howdy,

Those are environment variables… so one way to do that would be to edit the PHP script, and set those within the script itself. An example of doing that is here:

http://php.net/manual/en/function.putenv.php

Another way is that you can also set that from within the Apache config for your Virtual Host… you can do that with a line like this:

SetEnv LD_LIBRARY_PATH "/usr/local/lib/"

thank you!

one more total-idiot question: would the SetEnv command go into my http.conf file? i tried putting them in there but it didnt work.

is there a local file it goes into? (.htaccess sure didnt work !)

(this is a very brain-dead day for me…)

Howdy,

Where exactly it goes depends on your distro, but it’d be within the VirtualHost block for the domain in question. That’s usually either somewhere in httpd.conf (CentOS), in one of the files in /etc/apache2/sites-enabled/ (Ubuntu/Debian).

-Eric

hmmm well… i tried to include it in the httpd.conf (centOS) but it was ignored - i put it right below the DirectoryIndex part:

DirectoryIndex index.html index.shtml index.htm index.php index.php4 index.php5
SetEnv LD_LIBRARY_PATH "/usr/local/lib/"
SetEnv PKG_CONFIG_PATH "/usr/local/lib/pkgconfig/"
SetEnv LIBPATH "/usr/local/lib/"
<Directory /home/blahBlah.com/public_html>

however this works fine with the code in the php script itself as you suggested:

putenv('LD_LIBRARY_PATH=/usr/local/lib/');
putenv('PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/');
putenv('LIBPATH=/usr/local/lib/');

but the first way looks like a LOT more fun. any other suggestions?