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.

Thanks!

link|improve this question
feedback

3 Answers

up vote 1 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"
    ))
)
link|improve this answer
feedback

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.

#!/bin/sh
ENV=... /path/to/program
link|improve this answer
feedback

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

export MYVAR="something"

on top of the script or inside start() function

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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