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/passwd
www-data:x:33:33:www-data:/var/www:/bin/sh
I tried creating /var/www/.profile
with this line
export db_pass="password"
And 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 -version
Server version: Apache/2.2.14 (Ubuntu)
Server built: Feb 14 2012 16:42:25