How to install APC extension of PHP under Win

Source: Internet
Author: User
Tags apc
This tutorial will show you how to install APC on windows. I have successfully tested it on windowsserver2003. Of course, you can also use Windows XP as the test server. About APC
APC (Alternative PHP Cache) is a PHP Cache. It stores PHP pages in memory and reduces hard disk I/O. This significantly improves the performance. You can even increase the system performance by 50% when the CPU usage drops by 50%.

APC extension for installing PHP in windows
Note: you cannot install APC and Zend Optimiser on a single-day Server. either of them is required.
Follow the steps below to install APC extension for PHP.
Download the correct version
My PHP version is 5.3.10.
Note: Make sure that the expanded APC version you downloaded corresponds to your PHP version.
Set php. ini
Edit the php. ini file and add the following code to the expanded area section:
Extension = php_apc.dll
Restart the server and use phpinfo to check whether the installation is successful.
Phpinfo ();

Phpinfo: Check whether apc expansion is successfully installed
View available memory
Create a php file apcmeminfo. php
Print_r (apc_sma_info ());
// This formula is used to calculate the amount of memory used by the cache:
Total_memory = apc. shm_segments * apc. shm_size
In this example, the available memory is about 32 Mb. Generally, if we need to exceed 32 Mb in our cache, we should increase the number of segments used by APC. However, this can cause web server errors, so it is best to increase the size of the fragments. We should gradually increase the total amount of available cache to avoid memory loss.
The default APC is as follows:
The code is as follows:
Apc. cache_by_default = On
Apc. enable_cli = Off
Apc. enabled = On
Apc. file_update_protection = 2
Apc. filters =
Apc. gc_ttl = 3600
Apc. include_once_override = Off
Apc. max_file_size = 1 M
Apc. num_files_hint = 1000
Apc. optimization = Off
Apc. report_autofilter = Off
Apc. shm_segments = 1
Apc. shm_size = 30
Apc. slam_defense = 0
Apc. stat = On
Apc. ttl = 0
Apc. user_entries_hint = 100
Apc. user_ttl = 0
Apc. write_lock = On

For more information about the complete APC parameter settings, see http://www.php.net/apc.
The following is an APC block in php. ini. Paste them into your php. ini file:
The code is as follows:
Apc. enabled = 1
Apc. shm_segments = 1
Apc. shm_size = 64
Apc. max_file_size = 10 M
Apc. stat = 1

The default value is used for other settings.
Set temporary directory
APC requires a temporary directory to store files. It will try to cache files in the temporary directory of windows. please grant the write permission to the temporary directory in advance.
Monitoring and cache optimization



Monitor and optimize apc cache
The APC source contains a php script that is useful for monitoring and tuning the cache performance.
1, download APC monitoring File: http://pecl.php.net/package/apc
2. the apc. php file in the compressed package displays the APC monitoring information.
3. run this file and you will see a graph showing your cache statistics.
4. tune the Cache and view General Cache Information and Detailed Memory Usage and Fragmentation sections (overall Cache Information and Detailed Memory Usage and Fragmentation ).
5. monitor the Cache Full Count and fragment percentage. if the Cache Full Count is greater than 0, the Cache is Full and read/write frequently because there is not enough memory to be allocated. Increase apc. shm_size to solve the problem.
6. the fragment percentage should be 0%, but the value will increase as the memory reads and writes frequently.
Apc. php Security
Note the security of apc. php. you should use the security authentication method to control the information output of apc. php. for example:
The code is as follows:
// Moodle user Authentication
Require_once ("../config. php ");
Require_once ($ CFG ---> libdir. '/adminlib. php ');
Require_login ();
Require_capability ('moodle/site: config', get_context_instance (CONTEXT_SYSTEM, SITEID ));
// Disable APC Auth (APC Security authentication)
ULTS ('use _ AUTHENTICATION ', 0 );
//....

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.