Blog

APC Cache Activation and disable XCache

Tags: apccachephp

Published on: August 6, 2014 by Vipin R.N

APC Cache Activation and disable XCache

Scenario:

Scenario
A Client asked me to install APC Cache in his server and to disable XCache.

OS Cent OS
Control Panel cPanel/WHM
WebServer Apache 2
PHP version 5.x

 

Before we get into the details, lets take a look at some basics. XCache and APC Cache belong to the family of PHP Accelerators.

PHP Accelerator
A PHP accelerator is a PHP extension designed to improve the performance of software applications written in the PHP programming language.

Most PHP accelerators work by caching the compiled bytecode of PHP scripts to avoid the overhead of parsing and compiling source code on each request (some or even most of which may never be executed). To further improve performance, the cached code is stored in shared memory and directly executed from there, minimizing the amount of slow disk reads and memory copying at runtime.

PHP accelerators can substantially increase the speed of PHP applications. The effect on application performance of opcode caching varies widely, depending on factors such as the inherent execution time of the PHP application and the percentage of source code actually executed on a given request, and whether additional optimization steps are performed. While a code optimizer may even slow down overall performance when used in isolation, it can provide an additional performance boost when coupled with a bytecode cache, as the optimization effort is performed just once.

CMS Applications which involves complex PHP coding such as WordPress, Joomla etc make effective use of PHP Accelerators. The most popular PHP Accelerators are XCache and APC Cache.

Install APC Cache

(a) The Easy way aka WHM

Well, WHM is there. You can almost do anything with it 

After logging into WHM, navigate to Software » Module Installers then click on Manage against PHP Pecl. Search for “APC” in Find a PHP Pecl and then choose to “Install” in the APC result that will come up. Screenshots following :

pecl1

pecl2_1

pecl3

After installing it, you should see the Module listed :

pecl2

b) Via Shell

Lets go !

Before install APC cache, you’ve to ensure eAccelerator is enabled on the server .

Checking eAccelerator


# php -m | grep eAccelerator

eAccelerator

Go ahead now, the commands are self-explanatory


# cd /usr/local/src

# wget http://pecl.php.net/get/APC-3.0.19.tgz

# tar -xzf APC-3.0.19.tgz && cd APC-3.0.19
# phpize && ./configure –enable-apc –enable-apc-mmap –with-apxs=/usr/local/apache/bin/apxs –with-php-config=/usr/local/bin/php-config && make && make install

phpize: The phpize command is used to prepare the build environment for a PHP extension.

This should now configure APC and install it in your extension directory (can change from server to server). You can locate it from the PHP configuration file /usr/local/lib/php.ini at this line :

; Directory in which the loadable extensions (modules) reside.

extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20090626"

Now descend to the folder

[~]# cd /usr/local/lib/php/extensions/no-debug-non-zts-20060613

You can locate a file named apc.so in that directory.

You can now locate an entry for apc.so in the PHP configuration file /usr/local/lib/php.ini. Uncomment it if it was commented, finally the line should look like :

extension=”apc.so”

Disabling XCache is extremely easy, just comment the line to make it look like :

;extension="xcache.so"

Finally, restart the Webserver

/etc/init.d/httpd restart

Make a phpinfo page in any user accounts and confirm this. You should not see anything about XCache there, only APC. Just like this :

apc

Category : Apache, cPanel, Linux

Vipin R.N

Vipin R.N

Vipin is a no-nonsense, disciplined guy who ensures that everything is carried out with the highest level of perfection. Apart from his great coding skills, he is quite interested in advanced server administration, issue analysis, documentation and training. In-depth knowledge in international politics, ammunition and automobiles makes this hard core Manchester United fan, one of the most referenced personalities in the entire team.

You may also read:

Comments

Add new commentSIGN IN

Let's Connect

Categories

Your Cart

Cart is empty.

Subtotal
₹0.00
APPLY
0
Send this to a friend