How to Use the APC buffer PHP script to improve server performance-Linux Enterprise Application-Linux server application information, the following is a detailed description. Learn how to use APC to buffer PHP scripts to improve server performance.
Do you want your Web server to maximize its performance? If you are using a PHP script, you can easily use the php apc module to buffer php opcode, instead of forcing php to re-interpret every script at every execution. In a PHP5 System Supported by PEAR, the installation of APC is as simple as the execution of it, and is executed in the root directory:
# Pecl install APC
Some distribution versions may provide APC Binary packages, so you may be able to use urpmi php-apc or apt-get to install php-apc.
After APC is installed, edit/etc/php. ini to add the following content:
Extension = apc. so [apc] apc. enabled = 1apc. shm_segments = 1apc. shm_size = 30apc. optimization = 0apc. ttl = 7200apc. user_ttl = 7200apc. num_files_hint = 1000apc. mmap_file_mask =/tmp/apc. XXXXXX
This is done to activate the APC buffer, rather than starting the optimizer (currently in the experiment phase ). In addition to activating APC, you should note that important options include apc. ttl and apc. user_ttl, which define the time the script remains in the cache, in seconds. This is really important for servers that process a large number of files; it will prevent caching of old entries that cannot buffer new entries.
You can also adjust apc. num_files_hint, which provides an approximate value for APC, indicating the number of requested or included PHP source files in your system. The default value is 1000, but if you know that you want to process more files, you can increase the value to the nearest estimate. Similarly, if the number of files is large, the number of files can be reduced accordingly.
Finally, in the APC source package, there is a script named apc. php, which is used to obtain detailed data from the APC cache, so that you can further adjust the APC settings. To use this script, you need to edit the script and change the ADMIN_PASSWORD option. By adjusting the options and using this script to determine the effect of this change, you can truly improve the performance of the PHP script.
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.