How to install the APC extension _php tutorial for PHP under Win

Source: Internet
Author: User
Tags apc phpinfo
About APC
APC (alternative PHP cache) is a PHP buffer. It stores PHP pages in memory and reduces the I/O to the hard disk. This is a significant improvement in performance. You can even improve the performance of system 50% with a 50% decrease in CPU usage.

Installing the APC Extension for PHP under Windows
Note: You cannot install both APC and Zend Optimiser on a day server, only one of them can be selected.
Follow the methods below to install the APC extension for PHP.
Download the correct version
I'm using the PHP version is 5.3.10
Note: Make sure that the APC extension version you downloaded corresponds to your PHP version.
set PHP.ini
Edit the php.ini file to add the following code to the extended areas section
Extension = Php_apc.dll
Restart the server and use Phpinfo to see if the installation was successful
Phpinfo ();

Phpinfo See if the APC expansion was successfully installed
to view available memory
Create a PHP file apcmeminfo.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 Mb. In general, if we need to exceed Mb in our cache, we should increase the number of segments used by APC. However, this can lead to Web server errors, so it is best to increase the size of the fragment. We should gradually increase the amount of usable for the cache to avoid memory loss.
the default APC is as follows:
Copy CodeThe 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 refer to: HTTP://WWW.PHP.NET/APC.
The following is an APC block in a php.ini. Please paste them into your php.ini file:
Copy CodeThe 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 TEMP directory
APC requires a temporary directory to store the files. It will try to cache files in the temporary directory of Windows, please write permissions to the temporary directory beforehand.
Monitoring and tuning caching



Monitoring and tuning the APC cache
The APC source contains a PHP script that is useful for monitoring and tuning caching of performance.
1. Download APC Surveillance file: HTTP://PECL.PHP.NET/PACKAGE/APC
2, the apc.php file in the compressed package displays APC monitoring information.
3. Run this file and you will see a graph showing some statistics of your cache.
4, tune cache, view general cache information and detailed memory usage and fragmentation sections (overall cache information and detailed memory usage and fragmentation section).
5, monitor the cache full count and fragment percentage, if the cache is greater than 0, indicates that it is fully cached and reads frequently because there is not enough memory allocated. Adding apc.shm_size can solve the problem.
6, the fragment percentage should be 0%, but the value will rise as memory is read and written frequently.
Apc.php's Safety
Note that apc.php security should be used to control the apc.php information output using a secure authentication method, such as:
Copy CodeThe 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 safety certification)
Defaults (' Use_authentication ', 0);
//....

http://www.bkjia.com/PHPjc/328143.html www.bkjia.com true http://www.bkjia.com/PHPjc/328143.html techarticle APC Introduction APC (alternative PHP cache) is a PHP buffer. It stores PHP pages in memory and reduces the I/O to the hard disk. This is a significant improvement in performance. You can even use it on CPU ...

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