Install and use PHPAPC

Source: Internet
Author: User
Tags apc apc module php download
In the simplest way, find the pecl automatic installation in the php installation directory: # usrlocalphpbinpeclinstallapc. Follow the prompts to configure etcphp step by step. add extensionapc to the end of ini. so manual installation: cn2.php on the official website. netmanualzhbook. apc. php downloads pecl. php. netpacka

In the simplest way, find the pecl automatic installation in the php installation directory: #/usr/local/php/bin/pecl install apc and follow the prompts to complete step by step to configure/etc/php. add extension = apc to the end of ini. so manual installation: Official http://cn2.php.net/manual/zh/book.apc.php download http://pecl.php.net/packa

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

Add/etc/php. ini to 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

Print_r (apc_cache_info ());

?>

Note that it is not very friendly in the browser. 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 show that num_hits is changing, indicating that the cache has hit!

Stress TestingView results:

How to stress test read previous article http://blog.csdn.net/21aspnet/article/details/6595984

First, check to disable the apc function and configure it in php. ini.

# AB-n1000-c10 http: // 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.