APC installation in a Apache PHP environment


This year I wrote on how best to install Sugar CRM including installing the APC cache engine. I have just had call to install this again, and thought that really this could have a section of its own. I am a novice in the whole APC cache arena, but I a lead to believe that is works (and it does) straight out the box as they say. But you can tune, clear rotate the cache with the change of some settings, this maybe something that I look at in the future.

Anyway this is how you install it

Please note you will need the php-devel package installed. This may break your environment if you are running a non up todate PHP environment. Take note that the yum install will install the newest version of PHP that is contained in the repository..

yum install -y php-devel pcre pcre-devel
mkdir /opt/software
cd /opt/software
wget http://pecl.php.net/get/APC-3.1.9.tgz

tar -xvzf  APC-*.tgz

cd APC-*

phpize

You should receive the following

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

To configure APC you need to know where the php-config file was installed

whereis php-config

This should return something like

/usr/bin/php-config

When I ran .configure and make I got the following error, this was because I got the path statement wrong for the php-config file. Be careful it took me 20 minutes to work out what was wrong, copy and pasting has a lot to answer for 🙂

In file included from /opt/software/APC-3.1.9/apc.c:44:
/usr/include/php/ext/pcre/php_pcre.h:29:18: error: pcre.h: No such file or directory
In file included from /opt/software/APC-3.1.9/apc.c:44:
/usr/include/php/ext/pcre/php_pcre.h:37: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
/usr/include/php/ext/pcre/php_pcre.h:38: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
/usr/include/php/ext/pcre/php_pcre.h:44: error: expected specifier-qualifier-list before ‘pcre’
/opt/software/APC-3.1.9/apc.c:393: error: expected specifier-qualifier-list before ‘pcre’
/opt/software/APC-3.1.9/apc.c: In function ‘apc_regex_compile_array’:
/opt/software/APC-3.1.9/apc.c:454: error: ‘apc_regex’ has no member named ‘preg’
/opt/software/APC-3.1.9/apc.c:454: error: ‘apc_regex’ has no member named ‘preg’
/opt/software/APC-3.1.9/apc.c:455: error: ‘apc_regex’ has no member named ‘nreg’
/opt/software/APC-3.1.9/apc.c:455: error: ‘apc_regex’ has no member named ‘nreg’
/opt/software/APC-3.1.9/apc.c: In function ‘apc_regex_match_array’:
/opt/software/APC-3.1.9/apc.c:487: error: ‘apc_regex’ has no member named ‘preg’
/opt/software/APC-3.1.9/apc.c:487: error: ‘apc_regex’ has no member named ‘preg’
/opt/software/APC-3.1.9/apc.c:488: error: ‘apc_regex’ has no member named ‘nreg’
/opt/software/APC-3.1.9/apc.c:488: error: ‘apc_regex’ has no member named ‘nreg’
make: *** [apc.lo] Error 1

./configure –enable-apc –enable-apc-mmap –with-php-config=/usr/bin/php-config

make

make install

This has now installed apc, you need to tell php about this now.

There are two ways to do this depending on the version of php I believe, this is what I have surmised from the php.ini file from the following

;;;;
; Note: packaged extension modules are now loaded via the .ini files
; found in the directory /etc/php.d; these are loaded by default.
;;;;

If you do not have this note then just add the following to the file.

extension=apc.so

If you do have reference to the php.d directory then

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

You have to restart the Apache server  if it is started

service httpd restart
Advertisements

One Comment on “APC installation in a Apache PHP environment”

  1. […] Really we should install a cache engine, it usually helps PHP applications, use a helpful post by me to help you out APC installation in an Apache PHP environment […]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s