Home Backend Development PHP Tutorial php.ini 惯用 配置

php.ini 惯用 配置

Jun 13, 2016 pm 12:52 PM
ini php ps quot

php.ini 常用 配置

参考:http://legolas.blog.51cto.com/2682485/493917
这个文件必须命名为''php.ini''并放置在httpd.conf中的PHPIniDir指令指定的目录中。
最新版本的php.ini可以在下面两个位置查看:
http://cvs.php.net/viewvc.cgi/php-src/php.ini-recommended?view=co
http://cvs.php.net/viewvc.cgi/php-src/php.ini-dist?view=co
语法
该文件的语法非常简单。空白字符和以分号开始的行被简单地忽略。
章节标题(例如: [php])也被简单地忽略,即使将来它们可能有某种意义。
设置指令的格式如下:
directive = value
指令名(directive)是大小写敏感的!所以"foo=bar"不同于"FOO=bar"。
值(value)可以是:
1. 用引号界定的字符串(如:"foo")
2. 一个数字(整数或浮点数,如:0, 1, 34, -1, 33.55)
3. 一个PHP常量(如:E_ALL, M_PI)
4. 一个INI常量(On, Off, none)
5. 一个表达式(如:E_ALL & ~E_NOTICE)
INI文件中的表达式仅使用:位运算符、逻辑非、圆括号:
| 位或
& 位与
~ 位非
! 逻辑非
布尔标志用 On 表示打开,用 Off 表示关闭。
一个空字符串可以用在等号后不写任何东西表示,或者用 none 关键字:
foo =     ; 将foo设为空字符串
foo = none  ; 将foo设为空字符串
foo = "none" ; 将foo设为字符串''none''
如果你在指令值中使用动态扩展(PHP扩展或Zend扩展)中的常量,那么你只能在加载这些动态扩展的指令行之后使用这些常量。
httpd.conf ;;
还可以在httpd.conf中覆盖php.ini的值,以进行更灵活的配置:
php_value name value ;设置非bool型的指令,将value设为none则清除先前的设定
php_flag name on|off ;仅用于设置bool型的指令
PHP常量(如E_ALL)仅能在php.ini中使用,在httpd.conf中必须使用相应的掩码值。
带"SYS"标志的指令只能在httpd.conf中的全局配置部分使用,
带"ini"标志的指令不能在httpd.conf中使用,它们仅能用于php.ini中。
====================配置指令详解=======================================
常用PHP.INI配置项。
1--设置上传文件大小
file_uploads = on
upload_max_filesize = 8M
post_max_size = 8M
ps--post的数值要大于等于upload,否则upload不起作用。

2--设定一个脚本使用的最大内存
memory_limit = 128M

3--启用全局变量
register_gloables = on
ps--有些程序例如OSC需要启用全局变量.

4--设置默认编码
default_charset = 'iso--8859-1'
ps--这个一般不需要设置,因为大部分页面都有制定编码。

5--是否允许打开远程文件
allow_url_fopen = on

6--是否允许包含远程文件(include/require)
allow_url_include = false

7--时区
date.timezone = UTC
ps--php默认采用配置项中的时区,如果项目中涉及时区,请用date_default_timezone_get()/date_default_timezone_set(utc)来设定自己想要的时区。

8--禁用类/方法
disable_classes = 
disable_functions = 
ps-- 我的php.ini原来禁用了很多方法,会影响一些功能的使用,比如远程链接之类的。发送email应该回应想到。

9--设置错误报告级别
error_reporting = 
ps--日志级别是一些常量,在php.ini中有写,推荐使用 E_ALL | E_STRICT,即所有级别。


10--输出错误信息
display_error = off
ps--是否将错误信息作为输出的一部分,站点发布后应该关闭这项功能,以免暴露信息。


11--定义各个级别系统日志变量
define_syslog_variables = off
ps--建议关闭,以提高性能。

12--错误日志
error_log = 
ps-- 错误日志的位置,必须对web用户可写入,如果不定义则默认写入到web服务器的错误日志中去.
log_errors = on
ps--如上所说,建议将错误日志输出到文件,而不是直接输出到前端。
log_errors_max_length = 1024
ps--错误日志关联信息的最大长度,设为0表示无限长度。

13--默认socket时长
default_socket_timeout = 60

14--脚本最大执行时长
max_execution_time = 30
ps--设定每个脚本的最大执行时长,有助于阻止劣质脚本无限制占用服务器资源;0表示没有限制。


15--脚本最大输入时间
max_input_time = 60
ps--单个脚本最大输入时长

16--文件上传临时目录
upload_tmp_dir = 
ps--php进程用户可写目录,如果不设置,则采用系统临时目录。(tmp)


17--输出后自动刷新数据
implicit_flush = off
ps--是否在echo();printf();等输出数据块之后刷新;对性能影响严重,只建议在调试状态下开启。


Copy after login


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

In this chapter, we are going to learn the following topics related to routing ?

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

CakePHP Creating Validators CakePHP Creating Validators Sep 10, 2024 pm 05:26 PM

Validator can be created by adding the following two lines in the controller.

See all articles