How to install APC (Alternative PHP Cache) in Linux
To Install APC (Alternative PHP Cache) in Linux
APC -Alternate PHP Cache is an open source cache for PHP code. It provides robust framework for caching and optimizing PHP code. The procedures to install and enable APC caching for PHP in Linux is explained.
Installation of Dependency Packages for APC
Firstly install required packages namely pecl, phpize and apxs commands, in order to install APC using YUM package manager tool.
[root@linuxhelp1 ~]# yum install php-pear php-devel httpd-devel pcre-devel gcc make -y
Loaded plugins: aliases, changelog, fastestmirror, kabi, presto, refresh-packagekit, security, tmprepo, verify, versionlock
Loading support for CentOS kernel ABI
Setting up Install Process
Loading mirror speeds from cached hostfile
* base: centos.excellmedia.net
* extras: centos.excellmedia.net
* updates: centos.excellmedia.net
Package pcre-devel-7.8-7.el6.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package gcc.x86_64 0:4.4.7-16.el6 will be updated
--> Processing Dependency: gcc = 4.4.7-16.el6 for package: gcc-java-4.4.7-16.el6.x86_64
--> Processing Dependency: gcc = 4.4.7-16.el6 for package: gcc-gfortran-4.4.7-16.el6.x86_64
--> Processing Dependency: gcc = 4.4.7-16.el6 for package: gcc-c++-4.4.7-16.el6.x86_64
--> Processing Dependency: gcc = 4.4.7-16.el6 for package: gcc-objc-4.4.7-16.el6.x86_64
--> Processing Dependency: gcc = 4.4.7-16.el6 for package: gcc-gnat-4.4.7-16.el6.x86_64
.
.
.
Installed:
php-devel.x86_64 0:5.3.3-47.el6
Updated:
gcc.x86_64 0:4.4.7-17.el6 httpd-devel.x86_64 0:2.2.15-53.el6.centos make.x86_64 1:3.81-23.el6 php-pear.noarch 1:1.9.4-5.el6
Dependency Updated:
cpp.x86_64 0:4.4.7-17.el6 gcc-c++.x86_64 0:4.4.7-17.el6 gcc-gfortran.x86_64 0:4.4.7-17.el6
gcc-gnat.x86_64 0:4.4.7-17.el6 gcc-java.x86_64 0:4.4.7-17.el6 gcc-objc.x86_64 0:4.4.7-17.el6
gcc-objc++.x86_64 0:4.4.7-17.el6 httpd.x86_64 0:2.2.15-53.el6.centos httpd-manual.noarch 0:2.2.15-53.el6.centos
httpd-tools.x86_64 0:2.2.15-53.el6.centos libgcc.i686 0:4.4.7-17.el6 libgcc.x86_64 0:4.4.7-17.el6
libgcj.x86_64 0:4.4.7-17.el6 libgcj-devel.x86_64 0:4.4.7-17.el6 libgfortran.x86_64 0:4.4.7-17.el6
libgnat.x86_64 0:4.4.7-17.el6 libgnat-devel.x86_64 0:4.4.7-17.el6 libgomp.x86_64 0:4.4.7-17.el6
libobjc.x86_64 0:4.4.7-17.el6 libstdc++.x86_64 0:4.4.7-17.el6 libstdc++-devel.x86_64 0:4.4.7-17.el6
mod_ssl.x86_64 1:2.2.15-53.el6.centos php.x86_64 0:5.3.3-47.el6 php-cli.x86_64 0:5.3.3-47.el6
php-common.x86_64 0:5.3.3-47.el6 php-gd.x86_64 0:5.3.3-47.el6 php-ldap.x86_64 0:5.3.3-47.el6
php-mysql.x86_64 0:5.3.3-47.el6 php-odbc.x86_64 0:5.3.3-47.el6 php-pdo.x86_64 0:5.3.3-47.el6
php-pgsql.x86_64 0:5.3.3-47.el6 php-soap.x86_64 0:5.3.3-47.el6 php-xml.x86_64 0:5.3.3-47.el6
php-xmlrpc.x86_64 0:5.3.3-47.el6
Complete!
Installating APC Using PECL
Use PECL command to install it and ensure to select default settings when asked.
[root@linuxhelp1 ~]# pecl install apc
downloading APC-3.1.13.tgz ...
Starting to download APC-3.1.13.tgz (171,591 bytes)
.....................................done: 171,591 bytes
55 source files, building
running: phpize
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626
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) [no] :
Enable pthread read/write locks (EXPERIMENTAL) [yes] :
building in /var/tmp/pear-build-rootF4pGGV/APC-3.1.13
.
.
.
Build process completed successfully
Installing ' /usr/include/php/ext/apc/apc_serializer.h'
Installing ' /usr/lib64/php/modules/apc.so'
install ok: channel://pecl.php.net/APC-3.1.13
configuration option " php_ini" is not set to php.ini location
You should add " extension=apc.so" to php.ini
The following command enables APC extension in Apache configuration.
[root@linuxhelp1 ~]# echo " extension=apc.so" > /etc/php.d/apc.ini
Restart Apache Service for APC
Restart the Apache service to bring new changes.
[root@linuxhelp1 ~]# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
Verifing APC
Now you have to create a file info.php in Apache web root directory. For instance, /var/www/html/info.php
[root@linuxhelp1 ~]# vim /var/www/html/info.php
Next add the following code to it, then save and close.
< ?php phpinfo() ?>
Navigate to http://localhost/info.php
Enabling PHP administration
In order to enable APC administration panel, copy the following file.
[root@linuxhelp1 ~]# cp /usr/share/pear/apc.php /var/www/html/
Open the file apc.php with VI editor.
[root@linuxhelp1 ~]# vim /var/www/html/apc.php
Set your username and password in the file apc.php.
defaults(' ADMIN_USERNAME' ,' admin' ) // Admin Username defaults(' ADMIN_PASSWORD' ,' linuxc' ) // Admin Password - CHANGE THIS TO ENABLE!!!
Navigate to http://localhost/apc.php
To View Host information status, click View Host Stats tab.
To view cache entries, click System Cache Entries tab.3
Click User Cache Entries.
APC Login Screen prompts. Type the user credentials to authenticate.
Now enter the cache entries.
Click APC Version Check, to know your APC version.
To Upgrade using PECL
Execute following command to upgrade it. It will download and then upgrade APC.
[root@linuxhelp1 ~]# pecl upgrade apc
To Uninstall
Type the following command to uninstall APC completely from your machine.
[root@linuxhelp1 ~]# pecl uninstall apc
# pecl upgrade apc
# echo " extension=apc.so" > /etc/php.d/apc.ini
# pecl install apc
eAccelerator
ionCube PHP Accelerator
Turck MMCache
Xcache
https://www.linuxhelp.com/how-to-install-php-from-source-code-on-centos-6/
Could you please tell me what's the problem.
Thanks
Deepender