简体   繁体   English

如何从我的PHP应用程序覆盖php.ini和httpd.conf中的设置

[英]How to override settings in php.ini and httpd.conf from my php application

I don't have any access to the php.ini and httpd.conf files. 我无权访问php.ini和httpd.conf文件。 Are there any procedure to override (or add some) settings of php.ini and httpd.conf files from my php application? 是否有任何程序可以覆盖(或添加一些)来自我的php应用程序的php.ini和httpd.conf文件的设置?

For Apache configuration: this can (for certain settings) be done using .htaccess files: 对于Apache配置:可以(对于某些设置)使用.htaccess文件来完成:

.htaccess files (or "distributed configuration files") provide a way to make configuration changes on a per-directory basis. .htaccess文件(或“分布式配置文件”)提供了一种基于每个目录进行配置更改的方法。 A file, containing one or more configuration directives, is placed in a particular document directory, and the directives apply to that directory, and all subdirectories thereof. 包含一个或多个配置指令的文件放置在特定的文档目录中,这些指令适用于该目录及其所有子目录。

You may be unable to change certain settings using .htaccess files; 您可能无法使用.htaccess文件更改某些设置。 the directives that you can use are specified in the main Apache configuration using AllowOverride directives. 您可以使用的指令是在主Apache配置中使用AllowOverride指令指定的。

For PHP settings: this can be done using the ini_set function: 对于PHP设置:可以使用ini_set函数完成:

Sets the value of the given configuration option. 设置给定配置选项的值。 The configuration option will keep this new value during the script's execution, and will be restored at the script's ending. 配置选项将在脚本执行期间保留此新值,并将在脚本结尾处恢复。

This appendix shows you which settings can be changed from scripts. 本附录显示了可以从脚本更改的设置。

You can use ini_set() for some settings or by modifying the setting via .htaccess http://www.php.net/manual/en/ini.list.php 您可以将ini_set()用于某些设置,也可以通过.htaccess http://www.php.net/manual/en/ini.list.php修改设置

The changeability of ini settings using these methods varies depending on the variable (see "Changeable" column). 使用这些方法的ini设置的可变性取决于变量(请参见“可变”列)。 This page explains what each of those PHP_INI_* mean. 本页解释了每个PHP_INI_*含义。

For settings in httpd.conf (eg: that pertain to Apache itself rather than PHP), you'll need to use .htaccess files. 对于httpd.conf设置(例如:与Apache本身有关而不是与PHP有关),您将需要使用.htaccess文件。 But of course your server's AllowOverride has to allow you to use them. 但是,当然,您服务器的AllowOverride必须允许您使用它们。 Contact your hosting provider for information on this. 有关此信息,请与您的主机提供商联系。

For apache, use .htaccess , which will grant you control over much of what would httpd.conf would have given you. 对于apache,请使用.htaccess ,这将使您可以控制httpd.conf会给您的大部分内容。

For PHP look here: PHP: How to change configuration settings , one of the method is having settings put also in the .htaccess file (when certain php modules exist in the server). 对于PHP,请看这里: PHP:如何更改配置设置 ,方法之一是将设置也放入.htaccess文件中(当服务器中存在某些php模块时)。

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

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