Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set php include_path from nginx

Tags:

php

nginx

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?

like image 909
Sean Clark Hess Avatar asked Jul 31 '09 22:07

Sean Clark Hess


2 Answers

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!

like image 116
J. Bruni Avatar answered Sep 29 '22 14:09

J. Bruni


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);
like image 36
hobodave Avatar answered Sep 29 '22 12:09

hobodave