• Categories
    Category
  • Categories
    Category
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial Comments FAQ Related Articles

How to install APC (Alternative PHP Cache) in Linux

836

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
phpinfo

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.
view host information

To view cache entries, click System Cache Entries tab.3

Click User Cache Entries.
cache entries
APC Login Screen prompts. Type the user credentials to authenticate.
APC Login Screen prompts

Now enter the cache entries.
cache entries
Click APC Version Check, to know your APC version.
 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

Tags:
jacob
Author: 

Comments ( 1 )

singhdeepender891
Hello i did all steps. but when i checked with apc.php. website showing error (No cache info available. APC does not appear to be running.)
Could you please tell me what's the problem.

Thanks
Deepender
Add a comment

Frequently asked questions ( 5 )

Q

what are other php accelerators available in linux?

A

you can refer the following list

eAccelerator
ionCube PHP Accelerator
Turck MMCache
Xcache

Q

How to install php from source in linux?

A

refer the following link to install php from source in linux,
https://www.linuxhelp.com/how-to-install-php-from-source-code-on-centos-6/

Q

how to Install APC Using PECL in linux?

A

use the following command to install APC,
# pecl install apc

Q

which command enables APC extension in Apache configuration?

A

you can enables APC extension in Apache configuration by following command
# echo " extension=apc.so" > /etc/php.d/apc.ini

Q

how to To Upgrade APC using PECL?

A

by using following command to upgrade the APC
# pecl upgrade apc

Related Tutorials in How to install APC (Alternative PHP Cache) in Linux

Related Tutorials in How to install APC (Alternative PHP Cache) in Linux

How to Upgrade and Downgrade the PHP Versions on CentOS 7.6
How to Upgrade and Downgrade the PHP Versions on CentOS 7.6
Jun 4, 2019
How to install Multiple PHP versions on CentOS 6
How to install Multiple PHP versions on CentOS 6
Nov 2, 2017
How to Install PHP 7.3v from Source Code on CentOS 7.6
How to Install PHP 7.3v from Source Code on CentOS 7.6
Jun 12, 2019
How to install Webmin in OpenSUSE
How to install Webmin in OpenSUSE
Nov 7, 2016
How to update PHP in Centos Web Panel
How to update PHP in Centos Web Panel
Feb 14, 2017
How to install PHP 5.6 on CentOS 6.9
How to install PHP 5.6 on CentOS 6.9
Sep 22, 2017
How to setup Multiple PHP versions on Apache using FastCGI
How to setup Multiple PHP versions on Apache using FastCGI
Nov 23, 2017
How to install PHP eAccelerator on CentOS 7
How to install PHP eAccelerator on CentOS 7
Aug 4, 2017

Related Forums in How to install APC (Alternative PHP Cache) in Linux

Related Forums in How to install APC (Alternative PHP Cache) in Linux

Ubuntu
mason class=
"E: Package 'php-mcrypt' has no installation candidate" error on Ubuntu 20.4.1
Mar 15, 2021
Php
liam class=
The process /usr/local/bin/php artisan queue:work exceeded the timeout of 60 seconds
Jan 31, 2017
Nginx
levi class=
php files are downloading not executing in nginx
Apr 21, 2017
Php
stewart class=
Error: php70w-common conflicts with php-common-5.3.3-49.el6.x86_64
Sep 8, 2017
Apache
caden class=
how to use php variables in apache
May 12, 2017
CentOS
julian class=
Installation of php 5.6 on centos
Sep 19, 2017
Php
brayden class=
Cannot install php_fileinfo.dll
Feb 7, 2017
Kali Linux
elijah class=
Difference between php-CGi and php-CLI
May 12, 2017

Related News in How to install APC (Alternative PHP Cache) in Linux

Related News in How to install APC (Alternative PHP Cache) in Linux

PHP7 bugs used by hackers to remotely hijack web servers
PHP7 bugs used by hackers to remotely hijack web servers
Nov 5, 2019
Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Elijah ?
Remote Desktop Connection Has Stopped Working

When accessing my remote machine server using remote desktop on a windows machine I am getting this error

forum (1)

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.