If you want to install APC for PHP on Linux server then follow the below easy steps :
root@server[#] pecl install apc
Or
You can manually install it following the below steps :
root@server[#] wget http://pecl.php.net/get/APC
The above command will always downloads the latest version of APC
Now extract the downloaded zip file :
root@server[#] tar -zxf APC-3.1.9.tgz
root@server[#] cd APC-3.1.9
Now we need to execute ‘phpize’ command
This requires that you have PHP development package installed. On CentOS it is php-devel and which can be installed by running the command :
yum install php-devel
root@server[/usr/local/src/APC-3.1.9]# phpize Configuring for: PHP Api Version: 20090626 Zend Module Api No: 20090626 Zend Extension Api No: 220090626
Now we need to configure APC
If you are unsure as to where the php-configs files are located then use the below command to find the correct path
root@server[#] whereis php-config
php-config: /usr/bin/php-config /usr/local/bin/php-config /usr/man/man1/php-config.1
and then run the configure command like so:
./configure --enable-apc --enable-apc-mmap --with-apxs --with-php-config=/usr/bin/php-config
Now as configure is done, we need to run ‘make’ command:
root@server[#] make
and then make install:
root@server[#] make install
If everything goes well then you will get an output like this
Build process completed successfully Installing '/usr/local/include/php/ext/apc/apc_serializer.h' Installing '/usr/local/lib/php/extensions/no-debug-non-zts-20090626/apc.so' install ok: channel://pecl.php.net/APC-3.1.9 Extension apc enabled in php.ini
Finally just restart the web server to reflect the changes :
root@server[#] /etc/init.d/httpd restart
But if you encounter an error as below
/usr/local/src/APC-3.1.5/apc.c:461: error: syntax error before ')' token make: *** [apc.lo] Error 1
then just execute the below command :
root@server[#] yum install pcre-devel
After that again try “make” and “make install” commands and it will work for you now.
