Table of Contents
Resource Limit
Data processing
Path settings
File upload
Fopen Encapsulation
Date
session
资源限制
数据处理
路径设置
文件上传
Fopen 封装
日期
Home Backend Development PHP Tutorial Detailed explanation of common configurations in php.ini

Detailed explanation of common configurations in php.ini

Mar 31, 2018 am 11:00 AM
php php.ini Detailed explanation

This article mainly shares with you the detailed explanation of common configurations in php.ini, mainly in the form of text and code, hoping to help everyone.

Resource Limit

max_execution_time integer
Copy after login
Copy after login
  • This sets the maximum execution time, in seconds, allowed before the script is aborted by the parser. This helps prevent poorly written scripts from hogging server resources. The default setting is 30. When running PHP from the command line, the default setting is 0.

  • max_execution_time Only affects the running time of the script itself. Any other time spent outside the running of the script, such as calls to the system using the function system(), use of the sleep() function, database queries, file uploads, etc., are not included in the calculation The maximum time the script runs is not included.

  • The maximum execution time will not affect system calls and system operations. In safe mode you cannot modify this setting via ini_set(). The only solution is to turn off safe mode or modify the time limit in php.ini.

max_input_time integer
Copy after login
Copy after login

The maximum time allowed for the script to parse input data (similar to POST and GET), in seconds. It starts from receiving all data to starting to execute the script for measurement.

memory_limit integer
Copy after login
Copy after login

Maximum amount of memory a script may consume (default 128MB)

Data processing

post_max_size intager
Copy after login
Copy after login

allowed POSTMaximum byte length of data. This setting also affects file uploads. If the POST data exceeds the limit, then $_POST and $_FILES will be empty. To upload large files, this value must be greater than the value of the upload_max_filesize directive. If memory limit is enabled, this value should be less than the value of the memory_limit directive.

Path settings

include_path string
Copy after login
Copy after login

Specify a set of directories for require(), include(), fopen_with_path() functions to find files. The format is similar to the system's PATH environment variable (separated by colons under UNIX and separated by semicolons under Windows): UNIX: "/path1:/path2", Windows: "\path1;\path2". Use '.' in the include path to allow relative paths, which represent the current directory.

extension_dir string
Copy after login
Copy after login

The directory where extension libraries (modules) are stored is the directory used by PHP to find dynamic extension modules.

File upload

file_uploads boolean or integer
Copy after login
Copy after login

Whether HTTP file upload is allowed. The default value is On to allow HTTP file uploads. This option cannot be set to Off.

upload_tmp_dir string
Copy after login
Copy after login

The temporary directory where files are stored when uploading files (must be a directory writable by the PHP process user). If not specified PHP uses the system default temporary directory.

upload_max_filesize integer
Copy after login
Copy after login

The maximum size of files allowed to be uploaded.

max_file_uploads integer
Copy after login
Copy after login

The maximum number of files allowed to be uploaded simultaneously. As of PHP 5.3.4, upload fields left blank on submission do not count against this limit.

Fopen Encapsulation

allow_url_fopen boolean
Copy after login
Copy after login

This option activates the fopen encapsulation protocol of URL form making it possible to access URL objects such as files . The default encapsulation protocols provide ftp and http protocols to access remote files. Some extension libraries such as zlib may register more encapsulation protocols.

  • #Note: For security reasons, this option can only be set in php.ini.

allow_url_include boolean
Copy after login
Copy after login

This option allows the following functions to be encapsulated using URL-aware fopen: include, include, include_once, require, require_once. This setting requires the allow_url_fopen option to be enable.

default_socket_timeout integer
Copy after login
Copy after login

Default timeout in seconds for socket-based streams.

Date

date.timezone string
Copy after login
Copy after login

Define the default time zone used by date functions

session

session.use_strict_mode boolean
Copy after login
Copy after login

session.use_strict_modeSpecifies whether the module will use strict session ID mode. If this mode is enabled, the module does not accept uninitialized session IDs. If an uninitialized session ID is sent from the browser, a new session ID will be sent to the browser. Applications protect session pinning through strict mode session adoption. Default is 0 (disabled).

session.use_cookies boolean
Copy after login
Copy after login

session.use_cookies Specifies whether to use cookie on the client to store the session ID. Default is 1 (enabled).

session.cookie_secure boolean
Copy after login
Copy after login

session.cookie_secure Specifies whether cookies are only sent over secure connections . Default is off.

session.use_only_cookies boolean
Copy after login
Copy after login

session.use_only_cookies Specifies whether to only use cookie on the client to store the session ID. Enabling this setting prevents attacks involving session IDs being passed through URLs. This setting was added in PHP 4.3.0. As of PHP 5.3.0, the default has been changed to 1 (enabled)

session.name string
Copy after login
Copy after login

session.name 指定会话名以用做 cookie 的名字。只能由字母数字组成,默认为 PHPSESSID

session.auto_start boolean
Copy after login
Copy after login

session.auto_start 指定会话模块是否在请求开始时自动启动一个会话。默认为 0(不启动)

session.serialize_handler string
Copy after login
Copy after login

session.serialize_handler 定义用来序列化/解序列化的处理器名字。 当前支持 PHP 序列化格式 (名为php_serialize)、 PHP PHP 内部格式 (名为 php 及 php_binary) 和 WDDX (名为 wddx)。 如果 PHP 编译时加入了 WDDX 支持,则只能用 WDDX。 自 PHP 5.5.4 起可以使用 php_serialize。php_serialize 在内部简单地直接使用 serialize/unserialize 函数,并且不会有 php 和 php_binary 所具有的限制。 使用较旧的序列化处理器导致 $_SESSION 的索引既不能是数字也不能包含特殊字符(| and !)。 使用 php_serialize 避免脚本退出时,数字及特殊字符索引导致出错。 默认使用 php

session.gc_probability integer
Copy after login
Copy after login

session.gc_probabilitysession.gc_pisor 合起来用来管理 gc(garbag collection 垃圾回收)进程启动的概率。默认为 1

session.gc_pisor integer
Copy after login
Copy after login

session.gc_pisorsession.gc_probability 合起来定义了在每个会话初始化时启动gc(garbage collection 垃圾回收)进程的概率。此概率用 gc_probability/gc_pisor计算得来。例如 1/100 意味着在每个请求中有 1% 的概率启动 gc 进程。 将此值增加到1000会给你0.1%的几率gc将运行任何给出的请求。 对于大批量生产服务器,这是一个更有效的方法。

session.gc_maxlifetime integer
Copy after login
Copy after login

session.gc_maxlifetime integer 指定过了多少秒之后数据就会被视为“垃圾”并被清除。 垃圾搜集可能会在session 启动的时候开始( 取决于session.gc_probabilitysession.gc_pisor)。

  • Note:如果不同的脚本具有不同的 session.gc_maxlifetime数值但是共享了同一个地方存储会话数据,则具有最小数值的脚本会清理数据。此情况下,与 session.save_path 一起使用本指令。


详情请参考:http://www.cnblogs.com/cuchadanfan/p/6163970.html

资源限制

max_execution_time integer
Copy after login
Copy after login
  • 这设置了脚本被解析器中止之前允许的最大执行时间,单位秒。 这有助于防止写得不好的脚本占尽服务器资源。 默认设置为 30。 从命令行运行 PHP 时,默认设置为 0

  • max_execution_time 仅仅只影响脚本本身运行的时间。任何其它花费在脚本运行之外的时间,诸如用函数 system() 对系统的调用、sleep() 函数的使用、数据库查询、文件上传等,在计算脚本运行的最大时间时都不包括在内。

  • 最大执行时间不会影响系统调用和系统操作等。在 安全模式 下你不能通过 ini_set() 来修改此设置。唯一的解决方法是关闭安全模式或者在 php.ini 中修改时间限制。

max_input_time integer
Copy after login
Copy after login

脚本解析输入数据(类似 POST 和 GET)允许的最大时间,单位是秒。 它从接收所有数据到开始执行脚本进行测量的。

memory_limit integer
Copy after login
Copy after login

脚本可能消耗的最大内存量(默认 128MB)

数据处理

post_max_size intager
Copy after login
Copy after login

允许的POST数据最大字节长度。此设定也影响到文件上传。如果POST数据超出限制,那么$_POST$_FILES将会为空。要上传大文件,该值必须大于upload_max_filesize指令的值。如果启用了内存限制,那么该值应当小于memory_limit指令的值。

路径设置

include_path string
Copy after login
Copy after login

指定一组目录用于require(), include(), fopen_with_path()函数寻找文件。格式和系统的PATH环境变量类似(UNIX下用冒号分隔,Windows下用分号分隔):UNIX: "/path1:/path2",Windows: "\path1;\path2"。在包含路径中使用’.’可以允许相对路径,它代表当前目录。

extension_dir string
Copy after login
Copy after login

存放扩展库(模块)的目录,也就是PHP用来寻找动态扩展模块的目录。

文件上传

file_uploads boolean or integer
Copy after login
Copy after login

是否允许HTTP文件上传。默认值为On允许HTTP文件上传,此选项不能设置为Off。

upload_tmp_dir string
Copy after login
Copy after login

文件上传时存放文件的临时目录(必须是PHP进程用户可写的目录)。如果未指定则PHP使用系统默认的临时目录。

upload_max_filesize integer
Copy after login
Copy after login

允许上传的文件的最大尺寸。

max_file_uploads integer
Copy after login
Copy after login

允许同时上传的文件的最大数量。 从PHP 5.3.4开始,上传字段在提交时保持空白不计入此限制。

Fopen 封装

allow_url_fopen boolean
Copy after login
Copy after login

本选项激活了 URL 形式fopen 封装协议使得可以访问 URL 对象例如文件。默认的封装协议提供用 ftp 和 http协议来访问远程文件,一些扩展库例如 zlib 可能会注册更多的封装协议。

  • Note:出于安全性考虑,此选项只能在 php.ini 中设置。

allow_url_include boolean
Copy after login
Copy after login

此选项允许有以下功能使用URL识别的fopen封装:包括,include,include_once,require,require_once。此设置要求allow_url_fopen选项要开启

default_socket_timeout integer
Copy after login
Copy after login

基于 socket 的流的默认超时时间(秒)。

日期

date.timezone string
Copy after login
Copy after login

定义日期函数使用的默认时区

session

session.use_strict_mode boolean
Copy after login
Copy after login

session.use_strict_mode指定模块是否将使用严格的会话ID模式。 如果启用此模式,模块不接受未初始化的会话ID。 如果从浏览器发送未初始化的会话ID,则会将新的会话ID发送到浏览器。 应用程序通过严格模式的会话采用保护会话固定。 默认为0(禁用)。

session.use_cookies boolean
Copy after login
Copy after login

session.use_cookies 指定是否在客户端用 cookie 来存放会话 ID。默认为 1(启用)。

session.cookie_secure boolean
Copy after login
Copy after login

session.cookie_secure 指定是否仅通过安全连接发送 cookie。默认为 off

session.use_only_cookies boolean
Copy after login
Copy after login

session.use_only_cookies 指定是否在客户端仅仅使用 cookie 来存放会话 ID。启用此设定可以防止有关通过 URL 传递会话 ID 的攻击。此设定是 PHP 4.3.0 添加的。自PHP 5.3.0开始,默认值改为1(启用)

session.name string
Copy after login
Copy after login

session.name 指定会话名以用做 cookie 的名字。只能由字母数字组成,默认为 PHPSESSID

session.auto_start boolean
Copy after login
Copy after login

session.auto_start 指定会话模块是否在请求开始时自动启动一个会话。默认为 0(不启动)

session.serialize_handler string
Copy after login
Copy after login

session.serialize_handler 定义用来序列化/解序列化的处理器名字。 当前支持 PHP 序列化格式 (名为php_serialize)、 PHP PHP 内部格式 (名为 php 及 php_binary) 和 WDDX (名为 wddx)。 如果 PHP 编译时加入了 WDDX 支持,则只能用 WDDX。 自 PHP 5.5.4 起可以使用 php_serialize。php_serialize 在内部简单地直接使用 serialize/unserialize 函数,并且不会有 php 和 php_binary 所具有的限制。 使用较旧的序列化处理器导致 $_SESSION 的索引既不能是数字也不能包含特殊字符(| and !)。 使用 php_serialize 避免脚本退出时,数字及特殊字符索引导致出错。 默认使用 php

session.gc_probability integer
Copy after login
Copy after login

session.gc_probabilitysession.gc_pisor 合起来用来管理 gc(garbag collection 垃圾回收)进程启动的概率。默认为 1

session.gc_pisor integer
Copy after login
Copy after login

session.gc_pisorsession.gc_probability 合起来定义了在每个会话初始化时启动gc(garbage collection 垃圾回收)进程的概率。此概率用 gc_probability/gc_pisor计算得来。例如 1/100 意味着在每个请求中有 1% 的概率启动 gc 进程。 将此值增加到1000会给你0.1%的几率gc将运行任何给出的请求。 对于大批量生产服务器,这是一个更有效的方法。

session.gc_maxlifetime integer
Copy after login
Copy after login

session.gc_maxlifetime integer 指定过了多少秒之后数据就会被视为“垃圾”并被清除。 垃圾搜集可能会在session 启动的时候开始( 取决于session.gc_probabilitysession.gc_pisor)。

  • Note: If different scripts have different session.gc_maxlifetime values ​​but share the same place to store session data, the script with the smallest value will clean up the data . In this case, use this directive together with session.save_path.


The above is the detailed content of Detailed explanation of common configurations in php.ini. For more information, please follow other related articles on the PHP Chinese website!

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

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)

Hot Topics

Java Tutorial
1653
14
PHP Tutorial
1251
29
C# Tutorial
1224
24
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

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

PHP and Python: Comparing Two Popular Programming Languages PHP and Python: Comparing Two Popular Programming Languages Apr 14, 2025 am 12:13 AM

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

PHP: A Key Language for Web Development PHP: A Key Language for Web Development Apr 13, 2025 am 12:08 AM

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

See all articles