tags:

views:

587

answers:

2

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?

A: 

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);
hobodave
Thanks! I also found this link http://forum.slicehost.com/comments.php?DiscussionID=3087 - setting it using php itself isn't feasible because of the way the project is set up (no front controller).
Sean Clark Hess
I switched to the newer answer
Sean Clark Hess
+1  A: 

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!

J. Bruni
That is awesome! So much better!
Sean Clark Hess