I asked a question on dba.se about how I can give my Perl CGI script the password it needs to access the MySQL database it needs to query. I have received only one answer but that one suggests I save the password as an environmental variable.OK, apache2 runs as www-data and according to /etc/passwd, the user's $HOME is /var/www:$ grep www /etc/passwdwww-data:x:33:33:www-data:/var/www:/bin/shI tried creating /var/www/.profile with this lineexport db_pass=passwordAnd then had my Perl script print $ENV{db_pass} but that failed, the variable is empty. I checked with $ENV{PATH} and that was printed as expected.So, how can I set an arbitrary environmental variable for this user?The server is an Ubuntu Server running on a VM (which runs on Windows, not my choice, don't ask). $ apache2 -versionServer version: Apache/2.2.14 (Ubuntu)Server built:   Feb 14 2012 16:42:25
How can I set up environmental variables for www-data?
apache httpd;environment variables
You use Apache environment variable manipulation.So for example:SetEnv db_pass swordfishThis can be done in httpd.conf or in .htaccess. You can also set env vars in Rewrite Rules like this:RewriteRule someurl - [E=dbpass:swordfish]