带有nginx和子目录的php的.user.ini [英] php's .user.ini with nginx and subdirectory

查看:315
本文介绍了带有nginx和子目录的php的.user.ini的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了nginx 1.2.2和PHP 5.4.4.我已经用nginx作为FastCGI运行了PHP.

I have installed nginx 1.2.2 and PHP 5.4.4. I have configured PHP with nginx running as FastCGI.

nginx配置代码段:

nginx config snippet:

location ~ \.php$ {
    root           E:/Websites/localhost;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  E:/Websites/localhost/$fastcgi_script_name;
    include        fastcgi_params;
}

我有多个在同一系统上运行的本地虚拟站点.为了自定义每个要求,我在每个站点的根文件夹中创建了.user.ini文件,根据PHP文档,该文件也应适用于子文件夹.

I have a number of local virtual sites running on same system. To customize each ones requirements I have created .user.ini file in each sites root folder which as per the PHP documentation should be applicable on sub folders also.

请注意,这是一个开发环境,并非实时环境.因此,我可以灵活地自定义许多内容.

Please note this is a development environment and not live. So I have flexibility to customize a number of things.

当我从浏览器访问任何站点时,除非我不深入某些子文件夹,否则它都可以正常工作.似乎.user.ini在子目录中不起作用-至少在我的配置中.

When I access any site from the browser it works fine unless I do not dive into some sub folder. It seems that .user.ini does not work in sub directories - at least in my configuration.

根据PHP文档( http://www.php .net/manual/en/configuration.file.per-user.php ):

除了主要的php.ini文件外,PHP还会在每个文件中扫描INI文件 目录,,从所请求的PHP文件的目录开始,以及 一直到当前文档根目录

In addition to the main php.ini file, PHP scans for INI files in each directory, starting with the directory of the requested PHP file, and working its way up to the current document root

SOS

有人在nginx下配置了.user.ini-请您帮帮我.

SOS

Has anyone configured .user.ini under nginx - request you to please help me out.

注意:有人报告了2009年的一个错误: https://bugs.php.net /bug.php?id=50374

Note: Someone reported a bug in 2009: https://bugs.php.net/bug.php?id=50374

PHPInfo()表示(在根目录以及子文件夹中):
*服务器API: CGI/FastCGI
* user_ini.filename: .user.ini (本地和主用户)

PHPInfo() says (in root as well as in sub folders):
* Server API: CGI/FastCGI
* user_ini.filename: .user.ini (local as well as master)

php_sapi_name()说 cgi-fcgi

php_sapi_name() says cgi-fcgi

这些值存在于根目录和子目录的phpinfo()中.因此,PHPInfo()没有什么区别.

These values are present in phpinfo() from root folder and sub directories. So there is no difference in PHPInfo().

进一步确认它以 CGI/FastCGI 的身份运行是根文件夹正在从 .user.ini 而非子文件夹进行配置.

Further confirmation that it is running as CGI/FastCGI is that root folder is taking configurations from .user.ini but not sub folders.

// .user.ini
auto_prepend_file = "E:\Websites\localhost\user.ini.php"

// user.ini.php
<?php
printf('Hi from: %s', __FILE__);
?>

这实际上可能是一个错误,但是任何人都以这种方式用nginx配置了PHP,并且没有遇到问题.在这种情况下,要求共享版本号和平台.

This may actually be a bug but has anyone configured PHP with nginx in this way and did not faced the problem. Requesting to please share version numbers and platform in this case.

推荐答案

与nginx相比,这实际上是一个更大的问题,但可以使用永久解决方案.添加指令选项的另一种ini_set方法具有很大的局限性,因此它并不是一个很好的长期解决方案.谢谢.

This is actually a much bigger issue then just nginx, but a permanent solution is available. The alternative ini_set method of adding directive options has significant limitations so it is not really a good long term solution. Thanks. http://www.ait-pro.com/aitpro-blog/4349/misc-projects/wordpress-tips-tricks-fixes/php5-3-x-php5-4-x-user-ini-file-does-not-work-known-php5-3-x-user-ini-fastcgi-wordpress-zend-issue/

这篇关于带有nginx和子目录的php的.user.ini的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆