I. Introduction
PHP configuration item can be configured in the configuration file php.ini, you can use ini_set () function temporarily configured in the script.
Second, common configuration items
1 , the error message configuration
1)display_errors
Whether to set any PHP error message back to the Web server included in the data stream. (PHP error_reporting any error messages from the error defined as a data stream back to the Web server)
如:display_errors = On
2)error_reporting
Set error level PHP.
Error-level parameter list:
E_ALL: All errors and warnings (not including E_STRICT)
E_ERROR: fatal run-time error
E_WARNING: Warnings (non-fatal error) runtime
E_PARSE: parse error when compiling
E_NOTICE: remind runtime (These are often caused by a bug in your code, or it may be caused by intentional behavior.)
E_STRICT: coding standardization warning, allow PHP suggestions on how to modify the code to ensure the best interoperability forward compatibility.
E_CORE_ERROR: When PHP starts during initialization of a fatal error
E_CORE_WARNING: Warnings (non-fatal error) when PHP starts during initialization
E_COMPILE_ERROR: fatal compile-time error
E_COMPILE_WARNING: Warnings (non-fatal error) compile-time
E_USER_ERROR: user-defined error messages
E_USER_WARNING: user-defined warning messages
E_USER_NOTICE: user-defined alert message
Such as:
Error_reporting = E_ALL & ~ E_NOTICE; prompt addition, all errors are displayed
3)log_errors
PHP error reporting log function switch.
Such as: log_errors = On
4)error_log
PHP error reporting log file path.
如:error_log = "D:\www\php\php_errors.log"
5)display_startup_errors
Errors that occur during startup whether to print the php.
如:display_startup_errors = On
6)track_errors
Save a recent error / warning messages in the variable
php_errormsg This variable is only available within the scope of the error, and requires track_errors is open.
7)report_memleaks
Set whether the report memory leak information. This parameter only work in debug compile, and must be included in the error_reporting in E_WARNING.
8)error_prepend_string
The contents of the output before an error message.
如:error_prepend_string = "<span style='color: #ff0000'>"
9)error_append_string
Content output after an error message.
如:error_append_string = "</span>"
2 , resource constraints related configuration
1)post_max_size
POST method to submit data to the maximum size limit.
POST data allowed maximum byte length. This setting also affects file upload. If the POST data over the limit, $ _POST and $ _FILES will be empty. To upload large files, this value must be larger than upload_max_filesize directive value. If memory limit is enabled, then the value should be less than the value of memory_limit directive.
Such as: post_max_size = 8M
If PHP programs need to upload large data files such as photos and videos, it should increase the value of upload_max_filesize and post_max_size
2)memory_limit
PHP process can take up the maximum amount of memory, the unit is M, the default is 128M.
Such as: memory_limit = 128M
3)max_execution_time
Set any scripts to run the longest time, the default value is 30 seconds.
如:max_execution_time = 30
4)max_input_nesting_level
Set input variables nesting depth (e.g.
_POST, $ _ COOKIE, etc.).
如:max_input_nesting_level = 64
5)max_input_vars
Setting the maximum number of input variables (respectively applied to limit
_POST、$_COOKIE)。
Such as: max_input_vars = 1000
6)max_input_time
Provided each script received POST, GET and PUT, etc. enter the maximum time limit data.
如:max_input_time = 60
7)default_socket_timeout
Set socket timeout. Socket flow from creation to transmission and then shut down the entire process must be completed within the time parameter set, if not complete, PHP will automatically end the socket and returns a warning. For example: Using file_get_contents () function to get the file contents of time will be limited.
如:default_socket_timeout = 60
3 , file upload configuration
1)file_uploads
Whether to allow HTTP file uploads.
Such as: file_uploads = On
2)upload_max_filesize
Allow file uploads maximum size.
如:upload_max_filesize = 2M
3)max_file_uploads
Maximum number of files a request is allowed to upload restrictions.
Such as: max_file_uploads = 20
4) upload_tmp_dir
Storing files when file upload temporary directory (PHP processes must be user writable directory).
如:upload_tmp_dir = "D:/wamp/phpfileuploadtmp"
4 , the Session configuration
1)session.save_path
Set the location (folder should already exist) session files are stored.
如:session.save_path = "D:/www/phpsessiontmp"
2)session.save_handler
Session data access mode is provided. The default access to the papers.
如:session.save_handler = files
3)session.use_cookies
Whether the client uses cookies to save session sessionid, the default is the use of cookies.
如:session.use_cookies = 1
4)session.use_only_cookies
Whether using only save a session sessionid cookie on the client, this option allows administrators to prevent users to pass sessionid through URL, the default is 0, if disabled, if you disable a client session cookie will not work.
如:session.use_only_cookies = 1
5)session.name
Set session name.
Such as: session.name = PHPSESSID
6)session.auto_start
Whether to start the session automatically, by default does not start. If not start automatically, the head of each PHP script is required by session_start () function to start the session.
如:session.auto_start = 0
7)session.cookie_lifetime
The pass sessionid cookie is valid, 0 represents the effective period is only open in the browser.
如:session.cookie_lifetime = 0
8) session.gc_probability与session.gc_divisor
When you define each initialization session, start probability garbage collection program.
Formula: session.gc_probability / session.gc_divisor. The more frequent sessions of page views, the probability should be smaller.
如:session.gc_probability = 1、session.gc_divisor = 1000
9)session.gc_maxlifetime
Set the saved session file survival, more than this parameter setting the number of seconds, the saved data will be treated as 'junk' by the garbage collector to clean up. If you set session.save_path option to use subdirectories to store session data files, garbage collection program does not start automatically, you have to write your own shell scripts, cron entries or other ways to perform garbage collection.
如:session.gc_maxlifetime = 1440
10) session.use_trans_sid
When you set when the client is disabled Cookie, whether as a parameter sessionid will automatically appended to the end of the URL.
如:session.use_trans_sid = 1
Note: To use the configuration with the session.use_only_cookies = 0, otherwise invalid
5 , security-related configuration
1)register_globals
PHP when the process starts, according to register_globals settings to determine whether the $ _GET, $ _ POST, $ _ COOKIE, $ _ ENV, $ _ SERVER, $ REQUEST such as the contents of the array variable is automatically registered as global variables. (Note: Removed in PHP 5.4.0.)
The proposed closure of the configuration items, turn would increase the number of security vulnerabilities, and hide the source of the data. If you need to develop applications deployed in a register_globals open environment, you must make all variables are initialized before use, when register_globals is turned on, any use of uninitialized variables behavior means that the security loophole.
2)allow_url_fopen
Whether to allow open a remote file. (For security reasons, this option can only be set in php.ini.)
This option enables the URL of fopen wrappers that can access an object such as a file URL. The default encapsulation protocol provided with ftp and http protocols to access remote files, some extensions like zlib may register additional wrappers.
3)allow_url_include
This option allows the use of the following functions fopen package identified by a URL: including, include, include_once, require, require_once. This setting requires allow_url_fopen option to open.
4)safe_mode
Whether to enable secure mode.
When open, PHP will check the current owner of the same script file and whether the owner of the operation, the same operation is allowed, except the refuse operation. Safe Mode is turned on the premise of your directory file permissions have been fully allocated correctly. The open will slow down the program execution efficiency.
6 , language-dependent configuration
1)engine
Setting PHP engine is available, the default value is On, set to Off if you can not use PHP.
2)short_open_tag
Whether to allow PHP scripts use short, open-label, the "<? Php?>" To "<??>." But this same syntax XML, which in some cases can cause problems, it is generally recommended to close the item.
3)output_buffering
Setting whether to use an output buffer, or set the size of the output buffer. Using output buffering performance will drop slightly.
如:output_buffering = 4096
4)zend.enable_gc
Enable or disable garbage collection mechanism PHP.
Default: zend.enable_gc = On
7 , other configurations
1)date.timezone
The default date time zone definitions used by the function.
如:date.timezone = Asia/Shanghai
2)extension_dir
Storage extensions (modules) directory, that is, PHP should look for dynamically loadable extensions. PHP extensions files are stored in the ext directory under the PHP installation directory.
如:extension_dir = "D:\www\bin\php7.0.9\ext"
3)extension
For each need to activate the extension, requires a corresponding line "extension =" statement to explain which extensions need to be loaded when PHP starts.
Such as: extension = php_mysqli.dll
4)doc_root
PHP page root directory on the server.
如:doc_root = "D:\www"
5)include_path
Specify a set of directories used to require (), include (), fopen_with_path () function to find the file. Between directories separated by a colon under Unix, Windows, separated by semicolons.
如:include_path=".:/php/includes"、include_path=".;c:\php\includes"
6)sys_temp_dir
PHP is used to store temporary files.
如:sys_temp_dir = "/tmp"