从nginx设置php include_path

时间:2021-04-17 22:52:22

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

Apache允许您使用php_value指令为虚拟主机设置php.ini值。

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

nginx有类似的东西吗?是否有另一种方法可以在每个站点上设置include_path?

2 个解决方案

#1


25  

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

更多信息请访问: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.

使用此技术设置php值,我已成功为多个虚拟主机设置了不同的“error_log”位置。

Thanks, PHP and NginX guys!

谢谢,PHP和NginX家伙!

#2


1  

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

Sean,php_value和php_admin_value不适用于nginx。这是php-cgi的限制而不是nginx。

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

您可以通过启动PHP的多个实例并传入自定义php.ini来解决此问题,如下所示:

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

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

您还可以在PHP代码中显式设置包含路径,如下所示:

$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);

#1


25  

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

更多信息请访问: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.

使用此技术设置php值,我已成功为多个虚拟主机设置了不同的“error_log”位置。

Thanks, PHP and NginX guys!

谢谢,PHP和NginX家伙!

#2


1  

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

Sean,php_value和php_admin_value不适用于nginx。这是php-cgi的限制而不是nginx。

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

您可以通过启动PHP的多个实例并传入自定义php.ini来解决此问题,如下所示:

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

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

您还可以在PHP代码中显式设置包含路径,如下所示:

$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);