Programming + Design

Install APC on a WHM/CPanel based server PDF Print E-mail
Written by Brett Brewer   
Sunday, 06 April 2008

If you've ever tried to install the Alternative PHP Cache (APC) on your Linux server, you've probably tried to use the PECL installer and discovered that you just get an error. When this happens you will need to manually compile the module from source and install it yourself. It's actually quite easy, but it's a pain if you don't know how. Here's how it was done on one of my WHM/CPanel based servers. Please note, you may first wish to try the PECL package installer built into WHM, but that has never worked right for me, so below is a list of commands you can enter to install it manually from a root commandline.

APC is not compatible with the Zend Optmizer. Do not install APC if you are running the Zend Optimizer. I cannot stress this enough. You  can find out whether you are running PHP with the Zend Optimizer enabled (and most other information about your PHP install) by calling the phpinfo() function in any php script, or you can type "php -i|more" from the commandline to view the same info. Most of the stuff you'll need to pay attention to is on the first few pages. 

Once you have verified that you are not running the Zend optimizer you can continue with the steps below.

First, you might want to find out what version of PHP you are  running so you know which version of APC to download.... 

php -v

You might also want to make sure that it's not already installed/loaded, or that you are not running any incompatible modules, by listing your loaded PHP modules...

php -m

Now jump into your root dir, or wherever you want to download the files to...

cd /root/
mkdir download
cd download

Now get the applicable source files for your PHP version from the PECL repository, in this case I'm running PHP 5.2.5 on Apache 1.3 so I need... 


Now unpack the downloaded files...

tar xzf APC-3.0.18.tgz
cd APC-3.0.18

 Now build the module

make install

The extension should now be in your PHP extensions directory. If you don't know where that is, just enter the "php -i|more" command and it will be listed with the rest of the php config variables. Once you know your modules location you can verify that your new module has been installed in the proper directory by listing the location of your modules, which, in my case was...

ll /usr/local/lib/php/extensions/no-debug-non-zts-20060613/

Once you have verified that the new module exists at the proper location, you can add a line to your php.ini file to actually load the new module. I use nano as my text editor for such things...

nano /usr/local/lib/php.ini

    #edit the php.ini by adding the following to the modules section....

Now jump back to your root dir, verify the new module is installed and restart apache...

cd /
php -m
service httpd restart

Just to make sure Apache started okay, verify that there are some Apache processes...

pidof httpd

That's it! Of course, you can also add various other options to your php.ini file to customize the behavior of APC, but since you're reading this tutorial, you probably don't know enough about APC to intelligently tweak those options. For further reading I strongly suggest checking out the APC docs

Last Updated ( Sunday, 06 April 2008 )
< Prev   Next >


Who's Online

© 2017
Joomla! is Free Software released under the GNU/GPL License.