How to install APC in centos

Install Dependency Packages for APC

First, we need to install required packages called pecl, phpize and apxs commands, to installAPC using YUM package manager tool.

yum install php-pear php-devel httpd-devel pcre-devel gcc make

Install APC Using PECL

Now we have all the needed packages to install APC. Here we use PECL command to install it. Please select default settings when asked.

pecl install apc
Sample Output :
WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
downloading APC-3.1.9.tgz ...
Starting to download APC-3.1.9.tgz (155,540 bytes)
.................................done: 155,540 bytes
54 source files, building
running: phpize
Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
Zend Extension Api No:   220090626
config.m4:180: warning: AC_CACHE_VAL(PHP_APC_GCC_ATOMICS, ...): suspicious cache-id, must contain _cv_ to be cached
../../lib/autoconf/general.m4:1974: AC_CACHE_VAL is expanded from...
../../lib/autoconf/general.m4:1994: AC_CACHE_CHECK is expanded from...
config.m4:180: the top level
config.m4:180: warning: AC_CACHE_VAL(PHP_APC_GCC_ATOMICS, ...): suspicious cache-id, must contain _cv_ to be cached
../../lib/autoconf/general.m4:1974: AC_CACHE_VAL is expanded from...
../../lib/autoconf/general.m4:1994: AC_CACHE_CHECK is expanded from...
config.m4:180: the top level
Enable internal debugging in APC [no] :Enable per request file info about files used from the APC cache [no] :Enable spin locks (EXPERIMENTAL) [no] :Enable memory protection (EXPERIMENTAL) [no] :Enable pthread mutexes (default) [yes] :Enable pthread read/write locks (EXPERIMENTAL) [no] :

Enable APC PHP Extension

Run the following command to enable APC extension in Apache configuration.

echo "extension=apc.so" > /etc/php.d/apc.ini

Restart Apache Service for APC

Restart the Apache service to take new changes.

service httpd restart
OR
/etc/init.d/httpd restart

1, To monitering APC status, please cp /usr/share/pear/apc.php to you webroot directory, and point you browser to this url. before you doing it, please set username and password in apc.php.


2, I tested the speed, for example, when you define a string variable, PHP script will take 6900 microseconds, but with APC(saving variable in memory), it will only take 0 microseconds.


3, Please be careful about the memory sharing issue. Apc memory can be shared with every thread, so please care about the user related data when saving it in APC(memory).


4, APC example: apc_add('name', 'value', 'time') to add variable saved in memory, time is the expired time. default or 0 seconds means never expired.Apc_fetch to fetch apc variable.


5, Please load the apc extension to PHP when using it.


6, Please be careful about the PHP_mode and fastCGI when implement APC in use.


7, With php_mod, php thread always cost 20M be default.



你可能感兴趣的:(PHP,apc,caching)