Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

In my setup (debian etch, lighttpd), one one my websites is calling a program for some image manipulation via PHP, I think. I'd like to change the behavior of this program by setting an environment variable, preferably without changing the web app.

How to do this? =)

Setting the environemt variable for all processes owned by the www-data user would be ok, too, but I am usure if an entry in, say, .bashrc(?) would be respected in this scenario.


share|improve this question

3 Answers 3

up vote 4 down vote accepted

Since you are using lighttpd fast-cgi, just set it using bin-environment within the lighttpd settings.

## Start an FastCGI server for php (needs the php5-cgi package)
fastcgi.server    = ( ".php" => 
            "bin-path" => "/usr/bin/php-cgi",
            "socket" => "/tmp/php.socket",
            "max-procs" => 2,
            "idle-timeout" => 20,

            "bin-environment" => ( 
                    "PHP_FCGI_CHILDREN" => "4",
                    "PHP_FCGI_MAX_REQUESTS" => "10000",


            "bin-copy-environment" => (
                    "PATH", "SHELL", "USER"
            "broken-scriptfilename" => "enable"
share|improve this answer
How should we do to load multiple variable from the environment? Is it possible to give a file containing all the export ? – Jav Nov 23 at 17:10

You could build a wrapper script for the program, add your environment settings to it, and run the wrapper script instead of the original program.

ENV=... /path/to/program
share|improve this answer

It might work if you put it to lighttpd init script:

export MYVAR="something"

on top of the script or inside start() function

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.