Tuesday, March 19, 2013

Install APC on CentOS 5



APC (Alternative PHP Cache) is a free and open cache for PHP. It’s a free framework for caching and optimizing PHP intermediate code.
In other words, it could improve your php website performance

Here are some instructions on how install APC on CentOS 5 :

yum install php-pear php-devel httpd-devel pcre-devel apr-devel

pecl install apc

Create the file : /etc/php.d/apc.ini

extension = apc.so
apc.enabled=1
apc.shm_segments=3
apc.optimization=0
apc.shm_size=128
apc.ttl=7200
apc.user_ttl=7200
apc.num_files_hint=1024
apc.mmap_file_mask=/tmp/apc.XXXXXX
apc.enable_cli=1
apc.slam_defense=Off
apc.cache_by_default=1

Then restart Apache:
service httpd restart


Upon receving errors :
====================================
/usr/local/src/APC-3.1.5/apc.c:419: error: 'apc_regex' has no member named 'preg'
/usr/local/src/APC-3.1.5/apc.c:419: error: 'apc_regex' has no member named 'preg'
/usr/local/src/APC-3.1.5/apc.c:420: error: 'apc_regex' has no member named 'nreg'
/usr/local/src/APC-3.1.5/apc.c:420: error: 'apc_regex' has no member named 'nreg'
/usr/local/src/APC-3.1.5/apc.c: In function 'apc_regex_match_array':
/usr/local/src/APC-3.1.5/apc.c:452: error: 'apc_regex' has no member named 'preg'
/usr/local/src/APC-3.1.5/apc.c:452: error: 'apc_regex' has no member named 'preg'
/usr/local/src/APC-3.1.5/apc.c:453: error: 'apc_regex' has no member named 'nreg'
/usr/local/src/APC-3.1.5/apc.c:453: error: 'apc_regex' has no member named 'nreg'
make: *** [apc.lo] Error 1
======================================

Fix : yum install pcre-devel


Now to see if it is really working, create a file info.php in your DocumentRoot.

<?php
phpinfo();
?>

Start your browser and go to your.server.xx/info.php.
You’ll see something like this:

Now to see if it is really working, create a file info.php in your DocumentRoot.

<?php
phpinfo();
?>

Start your browser and go to your.server.xx/info.php.
You’ll see something like this :



Upon receiving the error :
================================
pecl/apc is already installed and is the same as the released version 3.1.9
install failed
==================================

Try : pecl install -f apc
             or
You can do a manual installation
==================
cd /usr/local/src
wget http://pecl.php.net/get/APC-3.1.12.tgz
tar -zxvf APC-3.1.12.tgz
cd APC-3.1.12
phpize
./configure
make && make install
 
 
 

No comments:

Post a Comment