Install and use PHP APC

Source: Internet
Author: User
Tags apc apc module

The simplest method is to find the PECL in the PHP installation directory.

Automatic installation:

#/Usr/local/PHP/bin/PECL install APC

Follow the prompts below to complete step by step

Configuration/Etc/PHP. iniAdd at the end
Extension = APC. So

Manual installation:

Official http://cn2.php.net/manual/zh/book.apc.php

Download the http://pecl.php.net/package/APC to find the latest

# Wget http://pecl.php.net/get/APC-3.1.9.tgz

# Tar-zxvf APC-3.1.9.tgz
# Cd APC-3.1.9
#/Usr/local/PHP/bin/phpize (production of configure files)
#./Configure-enable-APC-MMAP-with-PHP-Config =/usr/local/PHP/bin/PHP-config
# Make
# Make install

Copy and add an so file
# Cp/usr/local/lib/PHP/extensions/no-debug-zts-20060613/APC. So/usr/local/PHP/lib/PHP/extensions/APC. So
# Chmod 755/usr/local/PHP/lib/PHP/extensions/APC. So
Modify PHP. ini to enable the APC Module
Modify PHP. ini
Extension_dir = "./"
Extension_dir = "/usr/local/PHP/lib/PHP/extensions"
Add/etc/PHP. ini to the end
Extension = APC. So
APC. Enabled = 1
APC. cache_by_default = on
APC. shm_segments = 1
APC. shm_size = 128
APC. TTL = 7200
APC. user_ttl = 7200
APC. num_files_hint = 1024
APC. write_lock = on
APC. gc_ttl = 3600
APC. TTL = 0
APC. mmap_file_mask =/tmp/APC. xxxxxx
Restart Apache

#/Usr/local/apache2/bin/apachectl restart


Use APC

<? PHP

Print_r (apc_cache_info ());

?>

 

note that the browser is not very friendly. You can view the Source Code Of the webpage to see it clearly.

Array ([num_slots] => 1031 [TTL] => 0 [num_hits] => 4 [num_misses] => 1 [num_inserts] => 1 [expunges] => 0 [start_time] ==> 1322818377 [mem_size] => 4240 [num_entries] => 1 [file_upload_progress] => 1 [memory_type] => MMAP [locking_type] => spin locks [cache_list] => array ([0] => array ([type] => file [device] => 2049 [inode] => 883230 [filename] =>/var/www/TB. PHP [num_hits] => 4 [mtime] => 1322818340 [creation_time] => 1322818379 [deletion_time] => 0 [access_time] => 1322818482 [ref_count] => 1 [mem_size] => 4240 )) [deleted_list] => array () [slot_distribution] => array (

......

 

Multiple clicks can be foundNum_hitsThe cache is hit!

Stress TestingView results:

 

How to perform stress testingArticleHttp://blog.csdn.net/21aspnet/article/details/6595984

First, check to disable the APC function and configure it in PHP. ini.

# AB-n1000-C10Http: // localhost/TB. php

At this time, the throughput of requests per second is much higher than before.

 

 

============

Several other PHP cache tools

Xcache

Http://xcache.lighttpd.net/

Eaccelerator

http://sourceforge.net/projects/eaccelerator/

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.