The APC extension of PHP installed under win

Source: Internet
Author: User
Tags apc config count ini php file php script phpinfo version

Introduction to APC

APC (alternative PHP cache) is a PHP buffer. It stores PHP pages in memory and reduces the I/O to the hard drive. This is obvious for performance improvement. You can even improve the performance of system 50% with a 50% reduction in CPU usage.

In this tutorial we will show you how to install APC on Windows. I have successfully tested on Windows Server 2003. Of course, you can also use Windows XP as a test server.

APC Extensions for installing PHP under Windows

Note: You cannot install both APC and Zend Optimiser on a single day server, only one of them can be selected.

Follow the instructions below to install the APC extension for PHP.

Download the correct version

I am using the PHP version is 5.2.6, attached download address: Php_apc_dll for Php5_2_6

Note: Make sure your version of the APC version you downloaded corresponds to your PHP edition.

Set PHP.ini

Edit the php.ini file and add the following code to the Extension area section

Extension = Php_apc.dll

Reboot the server and use Phpinfo to see if the installation was successful

Phpinfo ();

Phpinfo See if APC expansion has been 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 computed using this formula:

Total_memory = apc.shm_segments * apc.shm_size

In this example, the available memory is about MB. Typically, if we need to exceed 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 fragment. We should progressively increase the amount of usable total for the cache to avoid memory loss.

The default APC 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 the complete parameter setting for APC, 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:

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 up a temporary directory

APC requires a temporary directory to store files. It will attempt to cache files in Windows Temp directory, please write permissions to the temp directory beforehand.

Monitoring and tuning caching

monitoring and Tuning APC cache

The APC source contains a PHP script that is useful for monitoring and tuning performance caching.

1, download APC Monitor file: HTTP://PECL.PHP.NET/PACKAGE/APC

2, the apc.php file in the package shows APC monitoring information.

3, run this file and you will see a graph showing your cache for some statistics.

4, tune the cache to view the general cache information and Detailed Memory Usage and Fragmentation sections (overall cache information and verbose memory usage and fragmentation).

5, monitor cache full count and percentage of fragments, if cache count is greater than 0, it means that caching is fully and reads frequently, because there is not enough memory to allocate. 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 write frequently.

the safety of apc.php

Pay attention to the safety of apc.php, should use security authentication way to control apc.php information output, for example:

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 certification)

Defaults (' 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.