简体   繁体   English

为什么使用了错误的php.ini?

[英]Why is the wrong php.ini being used?

I've got WordPress installed on an add-on domain ( shared hosting environment), with a theme that uses ini_get('allow_url_fopen') to determine how to reference post images. 我已经将WordPress安装在附加域( 共享托管环境)上,其主题使用ini_get('allow_url_fopen')确定如何引用帖子图像。 ini_get('allow_url_fopen') is returning a value different than what is in my custom php.ini file, which is located in the WP installation directory. ini_get('allow_url_fopen')返回的值不同于我的自定义php.ini文件中的值,该文件位于WP安装目录中。

If I run phpinfo() from a test file in the WP directory, I see that PHP is has these settings: 如果我从WP目录中的测试文件运行phpinfo(),则看到PHP具有以下设置:

Configuration File (php.ini) Path   /usr/lib
Loaded Configuration File   /home/ACCOUNT/public_html/ADD-ON DIRECTORY/php.ini

If, however, I run phpinfo() from /home/ACCOUNT/public_html/ADD-ON DIRECTORY/wp-content, a different configuration file is used: 但是,如果我从/ home / ACCOUNT / public_html / ADD-ON DIRECTORY / wp-content运行phpinfo(),则使用其他配置文件:

Configuration File (php.ini) Path   /usr/lib
Loaded Configuration File   /usr/local/lib/php.ini

Why is the wrong configuration file being loaded? 为什么加载了错误的配置文件?

Okay, my host is using suPHP. 好的,我的主持人正在使用suPHP。 And with suPHP (and, I presume, phpSuExec), subdirectories do not inherit the configuration from php.ini files. 借助suPHP(我假设是phpSuExec),子目录不会从php.ini文件继承配置。 (They will use the default php.ini.) (他们将使用默认的php.ini。)

http://www.geeksengine.com/article/php-include-path.html http://www.geeksengine.com/article/php-include-path.html

Two ways around this: 两种解决方法:

  • Place a custom php.ini file in each directory where scripts are loaded from 将自定义php.ini文件放在从中加载脚本的每个目录中
  • Use a suPHP_ConfigPath /home/username/public_html/ directive in .htaccess to point to the directory containing your custom php.ini and have it affect all subdirectories that don't already contain a php.ini 在.htaccess中使用suPHP_ConfigPath /home/username/public_html/指令指向包含您的自定义php.ini的目录,并使它影响所有尚未包含php.ini的子目录。

This is a problem related to your hosting company, not to php in particular. 这是与您的托管公司有关的问题,特别是与php有关的问题。 If you are using a specific system that you build yourself, you'll need to look at which apache extension is used to run php files. 如果您使用自己构建的特定系统,则需要查看使用哪个apache扩展名来运行php文件。

For example, on my system i built for work, i use SUPHP as a script engine. 例如,在为工作而构建的系统上,我使用SUPHP作为脚本引擎。 This allows me to configure where to look for a specific PHP.ini file. 这使我可以配置在何处查找特定的PHP.ini文件。

Good luck 祝好运

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM