Interpreting the basic concepts and configuration methods of php. ini _ PHP Tutorial

Source: Internet
Author: User
Describe the basic concepts and configuration methods of php. ini. We are learning 1. string defined by quotation marks (for example, "foo") 2. A number (integer or floating point number, for example, 0, 1, 34,-1, 33.55) 3. a php constant (for example, E_ALL, M_PI) 4. one that we are learning1. a string defined by quotation marks (for example, "foo ")

2. a Number (integer or floating point number, for example, 0, 1, 34,-1, 33.55)

3. a PHP constant (for example, E_ALL, M_PI)

4. an INI constant (On, Off, none)

5. an expression (for example, E_ALL &~ E_NOTICE)

Another option is to set a Boolean value. if 1 is On, it is enabled. if 0 is Off, it is disabled. Php. ini is divided into many parts, such as module, PHP global configuration, database configuration, and so on. After learning about the basic concepts, we can start our abnormal configuration journey.

The first important parameter is register_globals. this configuration affects how PHP receives the passed parameters. to put it bluntly, register_globals indicates registration as a global variable. Therefore, when this parameter is set to On, the passed value will be directly registered as a global variable for direct use. when the value of this parameter is Off, we need to get it from a specific array. Most PHP vulnerabilities at www.milw0rm.com are exploited when Register_Globals is On. Therefore, we strongly recommend that you change this parameter to Off, in the current top version of PHP, this parameter is Off by default. if you are using an old version, you must modify it here.

The second important parameter is magic_quotes_gpc. If you set magic_quotes_gpc to Off, PHP will not escape four types of characters (single quotation marks), "(double quotation marks), (backslash), and empty characters, in this case, the server may be injected illegally. However, if you set Magic_quotes_gpc to On, PHP will give $ _ POST, $ _ GET, $ _ if the preceding four characters exist in the COOKIE submitted variables, the backslashes are added. this will greatly improve the security of PHP. We strongly recommend that you set Magic_quotes_gpc to On.

The third important thing is display_errors. Why is this parameter important? because there are no developers who will not make mistakes, the display_errors parameter of PHP helps developers locate and determine these errors. However, if the information provided by PHP is known to hackers, this would be a bad thing. For example, if display_errors is not set, the web Directory is leaked. This is a very important information for hackers, because many times penetration requires the knowledge of web directories, such as webshell writing. Therefore, we strongly recommend that you set this parameter to Off.

The fourth important parameter is safe_mode, which is a common security mode. The PHP Security mode is a very important embedded security mechanism that can control some functions in PHP, such as system () and many File operation functions, access to some key files is not allowed, such as/etc/passwd, but the default php. ini does not enable the security mode. we can open it. Safe_mode = on.

The fifth parameter is open_basedir. Using the open_basedir option, you can control the PHP script to access only the specified directory. This prevents the PHP script from accessing files that should not be accessed, and limits the harm of webshell to a certain extent, generally, we can set it to only access the website directory (assume that the website directory is E: test): open_basedir = E: test. The sixth parameter is disable_functions, the use of disable_functions can restrict some functions that are very threatening to the system.

For example, we can see the PHP environment variables on the page with the PHPinfo () function in the first part. You can also use functions such as system and exec to execute system commands. Here we recommend the following filter functions. Disable_functions = PHPinfo, passthru, exec, system, chroot, scandir, chgrp, chown, shell_exec, proc_open,

Proc_get_status, ini_alter, ini_alter, ini_restore, dl, pfsockopen, openlog, syslog, readlink, symlink,

Popepassthru, stream_socket_server. If you do not know a function, you can search for the function by google to determine whether your server is disabled.

The seventh parameter is the Com component. A security vulnerability exists in the PHP script platform on Windows, allowing PHP to allow attackers to use COM () even in secure mode (safe_mode () function to create system components to execute arbitrary commands. The vulnerability occurs because although the system () and pathru () functions of the PHP platform in security mode are disabled, the setting of com. allow_dcom is still true. Attackers can use the COM () function to create system component objects to run system commands.

If the default Apache settings or the Web server runs with Loacalsystem or Administrators permissions, attackers can use this vulnerability to improve their permissions. Therefore, we must disable the com. allow_dcom parameter. the default value is True. we need to modify this parameter to com. allow_dcom = false. The eighth parameter is expose_PHP. This parameter determines whether PHP is exposed and installed on the server. If this parameter is set to On, the PHP version will be leaked. Our recommended value is Off.

Basically, we have finished introducing the parameters. of course, php. ini also needs to be configured. most of the settings have nothing to do with security, and most of them have to do with the PHP running effect (such as optimization, if you are interested, refer to the official PHP Manual for details. Note: After modifying php. ini, you must restart IIS. Otherwise, the content you set will not take effect immediately.


Lifecycle 1. string defined by quotation marks (for example, "foo") 2. A number (integer or floating point number, for example, 0, 1, 34,-1, 33.55) 3. a php constant (for example, E_ALL, M_PI) 4. one...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.