tags:

views:

151

answers:

2

Perhaps this has already been asked, but I'm brand new to lighttpd and I'd like to know how to configure it more thoroughly.

In Apache, you can set PHP flags and values as a part of your configuration:

php_flag error_reporting OFf php_value error_log /path/to/log/file.log

Is there a way to do the same with lighttpd?

For bonus points, a great tutorial on fully configuring PHP and lighttpd together would be an amazing link.

+1  A: 

Lighttpd Wiki suggests that it's not possible for the web server to pass php settings when running under CGI/FastCGI and that http://pecl.php.net/package/htscanner will allow php to interpret .htaccess files directly.

scribble
A: 

My experience matches what @scribble notes: you can't set PHP flags directly. However, you can have lighttpd pass environment variables to PHP, which are then accessible via $_SERVER. This is convenient if you need your application to configure itself dynamically based on the server it's running on. A shared configuration or initialization script can read the value from $_SERVER and use ini_set, etc. to configure itself.

Of course, if you only every use a single configuration, you could edit php.ini or add these changes directly to the application via ini_set.

Here's an example lighttpd configuration directive that passes MY_VARIABLE:

fastcgi.server = ( ".php" => ((
    "bin-path" => "/usr/local/bin/php-cgi",
    "socket" => "/tmp/php-fastcgi-"+var.PID+".socket",
    "max-procs" => 2,
    "bin-environment" => (
        "PHP_FCGI_CHILDREN" => "10",
        "PHP_FCGI_MAX_REQUESTS" => "100",
        "MY_VARIABLE" => "my-value"
    ),
    "bin-copy-environment" => (
        "PATH", "SHELL", "USER"
    ),
)))
PCheese