Install APC (Alternative PHP Cache) in CentOS 5/6/7 and Fedora 20/21

by | 2 Aug 2015 | APC, CentOS, Fedora, Linux, OS, PHP, Programming, Server, Technology | 0 comments

APC (Alternative PHP Cache) is a free and open source tool to cache PHP codes.

phpapc

1. Install Dependency Packages for APC

yum install php-pear php-devel httpd-devel pcre-devel gcc make -y

2. Install APC using PECL (PHP Extension Community Library)

pecl install apc

Press “Enter” for the following options

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) [yes] :
Enable pthread read/write locks (EXPERIMENTAL) [no] :

2a. [Alternative]

If the above command fails, you can use the following method to install APC as well.

yum install php-pecl-apc -y

3. Enable APC PHP Extension

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

4. Restart Apache Service for APC

CentOS

sudo service httpd restart

Fedora

/etc/init.d/httpd restart

5. Verify APC Installation

Create a file named phpinfo.php in Apache web root directory. For example our Apache web root directory is /var/www

nano /var/www/phpinfo.php

And add the following code to the php file

<?php phpinfo(); ?>

[Optional] If you do not have nano installed

yum install nano

Open the following url in your web browser

http://yourdomain.com/phpinfo.php

Screen Shot 2015-08-02 at 2.48.22 pm

 

6. Enable PHP APC administration

Copy the following file to any web directory that you want. For example, in this case we will copy it to the web root directory.

cp /usr/share/pear/apc.php /var/www/html/

Open the file apc.php 

nano /var/www/html/apc.php

In nano editor, use “Ctrl-w” to search for the username and password field to modify.

defaults('ADMIN_USERNAME','apc');       // Admin Username
defaults('ADMIN_PASSWORD','password');  // Admin Password - CHANGE THIS TO ENABLE!!!

Open the following link in your web browser.

http://yourdomain.com/apc.php

You should see your APC stats and that’s it!

 

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Related Posts

Amazon Web Services (AWS)ApacheCentOSDatabaseLinuxMySQLOSProgrammingServerTechnology
8 Simple Steps to Setup a Web Server with Apache Virtual Hosts & MySQL in Centos

8 Simple Steps to Setup a Web Server with Apache Virtual Hosts & MySQL in Centos

This tutorial will be guiding you in setting up a web server with pre-installed Centos. In summary, you will be installing Apache and MySQL, and learning how to configure virtual hosts in Apache. Note: before proceeding with this tutorial. Make sure you figure out...

AppleiOSMobile PhonesObjective-CProgrammingSwiftTechnology
How to install Cocoapods for Objective-C/Swift development on Mac OS?

How to install Cocoapods for Objective-C/Swift development on Mac OS?

Steps to install Cocoapods Cocoapods is used in Xcode IDE for development from iOS apps using Objective-C/Swift. Cocoapods helps developers add external libraries to their iOS project easily. The following tutorial guides you on the steps to install Cocoapods on...

AndroidAndroidAppleiOSJavaMobile PhonesObjective-CProgramming
iPhone Camera
Complete overview of the mobile app development process (Infographic)

Complete overview of the mobile app development process (Infographic)

Clients always have the misperception that developing a mobile app is as easy as developing a mobile application would be a walk in a park without much effort involved. The following infographic pretty much sums up the total cost and effort for mobile app...