Php. INI configuration file Roaming 2_php Tutorial

Source: Internet
Author: User
Tags php file upload hosting shared hosting
The first part of the article has led you to the structure of the php.ini file, and explains how to modify the PHP lookup path, error handling, and related options for the parser. The second section will delve into the configuration file, including how to activate PHP extension options, set resource limits for PHP scripts, and dynamically change configuration variables through PHP scripts. Activating extension options PHP can use a number of different extension options. In UNIX systems, the extended option needs to be created at compile time, and for Windows, the binary DLL file will be included in the PHP release. The variable extension_dir includes the name of the directory where PHP should view the relevant extension options. Extension_dir = "C:Program filesinternet toolsapacheinphp4extensions" PHP under Windows includes 20 different extension options, And all are listed in the php.ini file (via comments). To activate a specific extension option, simply remove the semicolon from the beginning of the line and restart the server. If you want to disable an extension option (for example, if you need to improve system performance), simply add the semicolon at the beginning of the line. If the extension option is not listed in the php.ini file, you can use the variable extension and pass the corresponding DLL file name to this variable. Extension=php_domxml.dll extension=php_dbase.dll Set extension-specific variable variable extension-specific is stored in a separate area in the configuration file. For example, all variables related to the MySQL extension function should be stored in the [MySQL] area of the php.ini. If you need to use the mail () function of PHP, you need to set the following three variables. SMTP and variable sendmail_from (Windows system) or variable Sendmail_path (Unix systems) are required when sending e-mail messages via the PHP mail () function. For Windows, these variables set the SMTP server used and the "From:" Address displayed in the e-mail message, whereas for UNIX, the variable Sendmail_path sets the MTA (message transfer agent, mail transfer Agent) path. SMTP = myserver.localnet.com Sendmail_from = me@localhost.com Sendmail_path =/usr/sbin/sendmail variable Java.class.path, Java.home, Java.library, and Java.library.path are all used to set the path to find Java classes and libraries. These values will be used by Java extensions, so if you want PHP to be properly integrated with your Java program, you must ensure that these variables are set correctly. Java.class.path =. Php_java.jar Java.home = c:jdk java.library = C:jdkjreinhotspotjvm.dll java.library.path=. The variable session.save_path specifies the temporary directory that is required to save the session information. Typically, this directory defaults to/TMP, but because this default directory does not exist on Windows systems, you must reset it to the correct Windows Temp directory, or the session handler will pop up a nasty error message when calling the Session_Start () function. The lifetime of the session cookie can also be controlled by variable session.cookie_lifetime. Session.save_path = c:windowsemp session.cookie_lifetime = 1800 security settings in PHP.ini, there are many variables related to security issues with the installation of PHP. The most interesting of these is the Safe_mode variable, which is recommended for ISPs and shared hosting services (shared-hosting services), which limits the user's scope of use of PHP. Safe_mode = OFF when Safe mode is on, you can use the variable safe_mode_include_dir to specify the directory in which to find the relevant file. By placing the binaries in a specific directory and using the Safe_mode_include_dir variable to tell the directory to php,php, you can limit the kinds of programs that are available to run PHP scripts using the EXEC () command. Only binary files in this directory can be accessed through the EXEC () command. Safe_mode_include_dir =/usr/local/lib/php/safe-include Safe_mode_exec_dir =/usr/local/lib/php/safe-bin can also be passed by variable open _basedir to restrict file operations. This variable will be set as the root (root) directory name for the file operation. After this variable is set, files stored outside of this directory tree will not be accessible to PHP. This limits the user to their own in the shared system.Home or web directories are a great way to do this. Open_basedir =/home/web/variable max_execution_time sets the time at which PHP waits for the script to complete before forcing the script to terminate, which is calculated in seconds. This variable is useful when the script enters an infinite loop state. However, this feature also causes the operation to fail when there is a legitimate activity that takes a long time to complete, such as uploading large files. In such cases, you must consider increasing the value of this variable to avoid PHP closing the script when the script is performing some important process. Max_execution_time = 90 just mentioned upload, now look at how to configure the uploads variable and the form variable. Profile uploads and form variables if the security features we discussed earlier in this article do not meet your requirements, you can further improve security by turning off file uploads or setting the maximum file size limit per upload. The above two functions will be implemented by variable file_uploads and upload_max_filesize respectively. Typically, you should set a relatively small limit on file size unless you have an application designed to receive files (such as a picture book based on a Web FTP service) in your system. File_uploads = on upload_max_filesize = 2M If you don't care about uploading files, but you use a lot of forms in your PHP application, there are two variables that will give you a lot of interest. The first is the variable register_globals, which solves a long-standing headache for PHP developers. In PHP 3.x, this variable defaults to ON. The form variables are automatically converted to PHP variables when the form is submitted. In PHP 4.x, this variable is set to off by default for security reasons. As a result, form variables will be accessible only through specific $_get and $_post. This also causes many scripts written in PHP 3.x to have problems at run time, requiring developers to rewrite and re-test the script. For example, entering a form field The value in the PHP 3.x script will be understood as "$_post[email", but in the PHP 4.x script is used as a "or $_get[email]." This variable can typically be set to OFF, which provides a more secure precaution against scripting attacks through forms. If you need to consider compatibility issues with earlier PHP 3.x scripts, you should put on. Register_globals = Off One of the variables associated with form submission is post_max_size, which controls the maximum amount of data that PHP can receive in a single form submission using the Post method. It seems unlikely that you need to change the default of 8 MB to a larger size. Instead, it should be appropriately lowered to a more realistic value. However, if you want to use PHP file upload functionality, you need to change this value to be larger than upload_max_filesize. Post_max_size = 8M added the max_input_time variable in PHP 5. This variable can be used in seconds to limit the time it takes to receive data by post, get, and put. If your application is running on a low-speed link, you need to increase this value to accommodate the additional time it takes to receive the data. Max_input_time = 90 Performance tuning You can also improve the performance of your PHP parser by adjusting some variable values. To prevent running scripts from using the system's available memory heavily, PHP allows you to define memory usage limits. Specify the maximum amount of memory that a single script can use by Memory_limit variables: memory_limit = 8M The value of the variable memory_limit should be greater than the value of post_max_size appropriately. Another way to improve performance is to disable the variable $ARGC and $ARGV, which are used to hold the number of arguments passed to the application on the command line, as well as the actual parameter values. REGISTER_ARGC_ARGV = False, you can also disable $http_get_vars and $http_post_vars because you are unlikely to use the first two methods today with $_get and $_post. Disabling this feature can result in a performance boost, but this can only be achieved with the variable register_long_arrays in PHP 5. Register_long_arrays = False function Ini_set () Finally, you need to be aware of the Ini_set () function. While PHP reads all the setup information in the php.ini configuration file, it also provides the ability to use the Ini_set () function to change these settings according to the Per-script principle. This function receives twoParameters: The name of the configuration variable that needs to be adjusted, and the new value of the variable. For example, increase the maximum execution time when a script appears (Maximum execution times): Such a setting will only affect the script being set. Once the script is executed, the variable is automatically restored to its original value. If the PHP application is running on a shared server, you are unlikely to have access to the main php.ini profile. At this point, the function Ini_set () can allow dynamic modification of the PHP configuration according to special requirements, which will bring you great convenience.

http://www.bkjia.com/PHPjc/531810.html www.bkjia.com true http://www.bkjia.com/PHPjc/531810.html techarticle The first part of the article has led you to the structure of the php.ini file, and explains how to modify the PHP lookup path, error handling, and related options for the parser. The second part will be in-depth matching ...

  • 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.