working - Set php include_path from nginx




php set_include_path not working (2)

Now, it is possible to do this way:

fastcgi_param  PHP_VALUE  "include_path=/my/include/path";

More information here: http://bugs.php.net/bug.php?id=51595

Using this technique to set php values, I have successfully set different "error_log" locations for multiple virtual hosts.

Thanks, PHP and NginX guys!

Apache lets you set php.ini values for virtual hosts with the php_value directive.

Does nginx have something similar? Is there another way to set the include_path on a per-site basis?


Sean, php_value and php_admin_value will not work with nginx. This is a limitation of php-cgi and not nginx.

You can work around this by starting multiple instances of PHP and passing in a custom php.ini like so:

php-cgi -c /path/to/php.ini

You can also set the include path explicitly in your PHP code like so:

$paths = array(
    PATH_PROJECT . 'lib/',
    PATH_PROJECT . 'lib/Doctrine/lib',
    PATH_PROJECT . 'application/doctrine/mappers/',
    PATH_PROJECT . 'application/lib',
    PATH_PROJECT . 'application/modules/',
    PATH_PROJECT . 'lib/classes',
    PATH_PROJECT . 'application/lib/reports/',
    get_include_path()
);

set_include_path(implode(PATH_SEPARATOR, $paths));
unset($paths);






nginx