PHP APC Cache Installation Configuration Tutorial

Source: Internet
Author: User
Tags apc apc module ini pthread mutex

The easiest way to find the PHP installation directory pecl

Automatic installation

#/USR/LOCAL/PHP/BIN/PECL Install APC

Then follow the prompts step-by-step to complete

Then configure the end of/usr/local/php/etc/php.ini to join

Extension=apc.so

Manual Installation

Official website: http://cn2.php.net/manual/zh/book.apc.php
Download: Http://pecl.php.net/package/APC Find the latest

Download APC

# wget Http://pecl.php.net/get/APC-3.1.13.tgz
# TAR-ZXVF Apc-3.1.13.tgz
# CD APC-3.1.13

Generating Configure Files

#/usr/local/php/bin/phpize

Perform configure and make && make install

#./configure--ENABLE-APC--enable-apc-mmap--with-php-config=/usr/local/php/bin/php-config
# make
# make Install

Copy add so file

# cp/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/apc.so/usr/local/php/lib/php/extensions/apc.so
# chmod 755/usr/local/php/lib/php/extensions/apc.so

Modify the php.ini to start the APC module

# Vi/usr/local/php/etc/php.ini
Extension_dir = "/usr/local/php/lib/php/extensions"
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

# Service httpd Restart

using APC

test.php

<?php
Print_r (Apc_cache_info ());

Note in the browser will not be very friendly, you can see the source code of the Web page is very clear

Array
(
[Num_slots] => 1031
[TTL] => 0
[Num_hits] => 3
[Num_misses] => 1
[Num_inserts] => 1
[Expunges] => 0
[Start_time] => 1398341530
[Mem_size] => 4240
[Num_entries] => 1
[File_upload_progress] => 1
[Memory_type] => mmap
[Locking_type] => pthread Mutex Locks
[Cache_list] => Array
(
[0] => Array
(
[Type] => file
[Device] => 64768
[Inode] => 1179758
[FileName] =>/data/www/www.111cn.net/test.php
[Num_hits] => 3
[Mtime] => 1398341609
[Creation_time] => 1398341617
[Deletion_time] => 0
[Access_time] => 1398341630
[Ref_count] => 1
[Mem_size] => 4240
)

)

[Deleted_list] => Array
(
)

[Slot_distribution] => Array
(
[109] => 1
)

)

Multiple clicks, you can find num_hits in the change, description cache hit!

Pressure test to see the effect

Turn off the APC, separate the pressure tests. You will find that the throughput is much better than not opening the APC after you open the APC.

# AB-N1000-C10 http://www.111cn.net/test.php

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.