Home  >  Article  >  Backend Development  >  How to install the APC extension for PHP under Win_PHP Tutorial

How to install the APC extension for PHP under Win_PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 14:59:33718browse

APC Introduction
APC (Alternative PHP Cache) is a PHP cache. It stores PHP pages in memory and reduces hard disk I/O. This is a very obvious improvement in performance. You can even increase system performance by 50% while reducing CPU usage by 50%.

Install APC extension for PHP under windows
Note: You cannot install APC and Zend Optimiser at the same time on the server, you can only choose one of the two.
Follow the following method to install the APC extension for PHP.
Download the correct version
The PHP version I am using is 5.3.10
Note: Make sure the APC extension version you download corresponds to your PHP version.
Set php.ini
Edit the php.ini file and add the following code to the extension area
extension = php_apc.dll
Restart the server and use phpinfo to check whether the installation is successful
phpinfo();

phpinfo to check whether the apc extension is installed successfully
Check the available memory
Create a php file apceminfo.php
print_r(apc_sma_info());
//The amount of memory used by the cache is calculated using this formula:
total_memory = apc.shm_segments * apc.shm_size
In this example, the available memory is approximately 32 Mb. Generally, if we need more than 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 better to increase the fragment size. We should gradually increase the total amount available for the cache to avoid memory loss.
The default APC is as follows:

Copy the code 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 = 1M
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 an explanation of APC’s complete parameter settings, please check: http://www.php.net/apc.
Below is an APC block in a php.ini. Please paste them into your php.ini file:
Copy the code The code is as follows:

apc.enabled = 1
apc.shm_segments = 1
apc.shm_size = 64
apc.max_file_size = 10M
apc.stat=1

The remaining settings will use the default values .
Set a temporary directory
APC requires a temporary directory to store files. It will try to cache the file in the Windows temporary directory. Please give write permission to the temporary directory in advance.
Monitor and tune cache



Monitor and tune apc cache
APC source contains a php script , this script is useful for monitoring and tuning performance of the cache.
1. Download the 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 some statistics of your cache.
4. To tune the cache, view the General Cache Information and Detailed Memory Usage and Fragmentation sections.
5. Monitor Cache Full Count and fragmentation percentage. If Cache Full Count is greater than 0, it means that the cache is full and is frequently read and written because not enough memory is allocated. Increasing apc.shm_size can solve the problem.
6. The fragmentation percentage should be 0%, but as the memory is frequently read and written, its value will increase.
Security of apc.php
Pay attention to the security of apc.php. Security authentication should be used to control the information output of apc.php, such as:
Copy code 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)
defaults('USE_AUTHENTICATION',0);
//....

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/328143.htmlTechArticleAPC Introduction APC (Alternative PHP Cache) is a PHP cache. It stores PHP pages in memory and reduces hard disk I/O. This is a very obvious improvement in performance. You can even use it on the CPU...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn