PHP配置,php.ini以及覆盖问题
在部署一个cms项目到服务器上的时候,因为cms的模板比较老,服务器上用的php是5.3.3版(大于5.3,可以认为是新的),有些页面会显示“deprecated”类别的错误信息。安全起见要抑制页面中的错误信息输出,于是修改php.ini,发现error_reporting已经设定为Off了,表示错误输出到日志文件而不在页面上显示。但是,页面上有显示错误啊!
Google一番后在SO上发现了解决方案,是因为配置的覆盖问题,cms源代码中会覆盖php.ini的配置。那么改动cms中的error_reporting语句就可以解决问题了,比如:
if ((DEBUG_MODE & 1) == 1)
{
error_reporting(E_ALL & ~E_DEPRECATED);
}
以下是详细的解释,来自Stefano Locati的博客
PHP Configuration, php.ini and overrides
PHP has several places where configuration can be set. While I had an idea of the precedence of those settings, I decided to test them experimentally to be sure of what I am going to say. In particular this post is focused on error_reporting, but the same considerations can hold true for any setting.
So here is a list of those places, from the more global to the more specific. Each setting lower in the list can override a setting that come before.
1. The php.ini configuration file. In case of Ubuntu there are two of them, /etc/php5/apache2/php.ini is the one used for php apache module. It will have a global effect on all virtual hosts.
2. The conf.d directory. Actually not all installations will have this modularized configuration, but in case of Ubuntu is located in /etc/php5/apache2/conf.d for the apache module. Any file added in this directory is going to be added to main php.ini configuration with higher precedence than php.ini. In other words any setting here will override settings in php.ini - I tested adding an error.ini. It will have a global effect on all vitual hosts.
3. Apache virtual host configuration. Generally set in /etc/apache2/sites-available, every virtual host can have different settings. Inside the VirtualHost tag it's possible to include "php_value error_reporting ", where value is the numeric result of the boolean operations on the constants. In this configuration, in fact is not allowed to use the mnemonic constants but only a numeric value. It will affect only a single virtual host. It will override above settings.
4. .htaccess. It's also possible to set configuration values and in particular the error_reporting setting also in .htaccess, with the same syntax described in 3. It will affect only the directory in which .htaccess is located and all subdirectories. It will override above settings, in this case is not necessary to restart apache.
5. Source code. The last place where this setting can be altered is directly in the executed PHP source. If used, will override all previous settings. It can be set calling the function "error_reporting()" or with "ini_set("error_reporting", )". Compile errors could still show, because the script won't be executed in that case.
PHP配置,php.ini以及覆盖问题的更多相关文章
- 配置php.ini实现PHP文件上传功能
本文介绍了如何配置php.ini实现PHP文件上传功能.其中涉及到php.ini配置文件中的upload_tmp_dir.upload_max_filesize.post_max_size等选项,这些 ...
- 关于PHP上传文件时配置 php.ini 中的 upload_tmp_dir
在<PHP 5.3 入门经典>9.6.3 的试一试中(P235),给出了一个上传文件的例子,这里的文件格式为jpeg图片(image/jpeg).如果之前未配置 php.ini 中的 up ...
- Python3:读取配置dbconfig.ini(含有中文)显示乱码的解决方法
Python3:读取配置dbconfig.ini(含有中文)显示乱码的解决方法 一.原因 Python 3 中虽有encoding 参数,但是对于有BOM(如Windows下用记事本指定为utf-8) ...
- WAMP3.1 安装php_redis.dll扩展并配置php.ini
一. 下载对应版本的php_redis.dll 下载地址:http://windows.php.net/downloads/pecl/releases/redis 注:php7目录下有php7.dll ...
- 绿色安装MySQL5.7版本----配置my.ini文件注意事项
前言 由于前段时间电脑重装,虽然很多软件不在C盘,但是由于很多注册表以及关联文件被删除,很多软件还需要重新配置甚至卸载重装. 使用MySQL时就遇到了这种情况,在修改配置文件无效的情况下选择了重新安装 ...
- MySQL数据库安装,配置My.ini文件
最近在做项目开发时用到了MySql数据库,在看了一些有关MySql的文章后,很快就上手使用了.在使用的过程中还是出现了一些问题,因为使用的是绿色免安装版的MySql所以在配置的时候出现了一些问题,该篇 ...
- 黄聪:php7配置php.ini使其支持<? ?>
<? ?>这种写在php配置文件里php.ini法叫short_tags,默认是不打开的,也就是,在默认配置的php里,这样写法不被认为是php脚本的,除非设置 short_open_ta ...
- win7下iis中配置php.ini文件
将php.ini-development配置文件重命名为php.ini配置文件即可. 接着做如下配置操作: 1.修改php.ini配置文件 打开php.ini配置文件,找到 12 ; On windo ...
- php性能优化二(PHP配置php.ini)
PHP优化对于PHP的优化主要是对php.ini中的相关主要参数进行合理调整和设置,以下我们就来看看php.ini中的一些对性能影响较大的参数应该如何设置. # vi /etc/PHP.ini (1) ...
随机推荐
- SGU 174 Walls
这题用并查集来做,判断什么时候形成了环即判断什么时候加入的线段两个端点原先是属于同一集合的.对于一个点,有两个坐标x,y,不好做并查集操作,于是要用map来存储,即做成map<node,int& ...
- iOS math.h数学函数
在实际工作中有些程序不可避免的需要使用数学函数进行计算,比如地图程序的地理坐标到地图坐标的变换.Objective-C做为ANSI C的扩展,使用C标准库头文件<math.h>中定义的数学 ...
- App_api设计
2014年,移动APP的热度丝毫没有减退,并没有像桌面软件被WEB网站那样所取代,不但如此,越来越多的传统应用.网站也都开始制作自己的移动APP,也就是我们常说的IOS客户端.android客户端.这 ...
- StackBlur.js
StackBlur.js 是 Mario Klingemann 创建的一个快速的.接近高斯模糊的效果库. 更多信息: http://incubator.quasimondo.com/processin ...
- uniq-sort-awk
题目:[百度搜狐面试题] 统计url出现次数 oldboy.log http://www.etiantain.org/index.html http://www.etiantain.org/1.htm ...
- js中的预加载与懒加载(延迟加载)
js中加载分两种:预加载与延迟加载 一. 预加载,增强用户的体验,但会加载服务器的负担.一般会使用多种 CSS(background).JS(Image).HTML(<img />) . ...
- [转]仿World Wind构造自己的C#版插件框架——WW插件机制精简改造
很久没自己写东西啦,早该好好总结一下啦!一个大师说过“一个问题不应该被解决两次!”,除了一个好脑筋,再就是要坚持总结. 最近需要搞个系统的插件式框架,我参照World Wind的插件方式构建了个插件框 ...
- Android调用基于.net的WebService
在实际开发项目中,有时候会为Android开发团队提供一些接口,一般是以asmx文件的方式来承载.而公布出去的数据一般上都是标准的json数据.但是在实际过程中,发现Android团队那边并不是通过将 ...
- 三层ViewPager嵌套 的事件处理
这么多ViewPager嵌套在一起肯定会遇到冲突 不信你试试(笑脸) 下面来说怎么解决.....太为难我这个菜b了 设置外部的父控件不要拦截我子控件的事件,通过重写ViewPager的 @Overri ...
- "互联网思维"背后的谎言
互联网公司/思维是什么鬼,说来惭愧上学的时候还因为知道www(World Wide Web)的中文名自豪了好久,之后在”高等学府“里学习软件工程,还愚蠢的以为自己步入了互联网之门. internet嘛 ...