Install APC Accelerator On Bluehost Shared Host

I’ve used eAccelerator and XCache for quite some to speed up my WordPress sites, but with PHP6 around the corner, I wanted to get my feet wet with alternative PHP cache (APC) – an opcode cacher which will be built into the next generation of PHP. This is a walkthrough for how to install APC in a shared hosting environment (BlueHost in my case).

Before beginning, you’ll need to have SSH access to your server for compiling the APC module and have your php.ini file accessible (usually directly under public_html). Once you’ve SSHed into your box, execute the following commands in order.

  1. cd ~
  2. mkdir modules apc
  3. cd apc
  4. wget
  5. tar -xzvf APC-3.1.8.tgz
  6. cd APC-3.1.8
  7. phpize
  8. ./configure --enable-apc --enable-apc-mmap --with-apxs --with-php-config=/usr/bin/php-config
  9. make
  10. cd modules
  11. mv /home/BLUEHOST-USERNAME/modules

Steps 1-6 create the necessary directories we’ll be using, download the latest stable APC file, extract it, and point to the directory.

Steps 7-9 compile the APC module according to the PHP version your server is running.

Steps 10-11 move the newly compiled module ( to a readily accessible directory which we will define in our php.ini file.

Now FTP into your box, create a backup of your php.ini file (/public_html/php.ini) and proceed to edit the original php.ini with a text editor program (ie, Wordpad for Windows, TextEdit for Mac OS X, Gedit for Linux).

Using the “Find” function, search for “extension_dir.” Place a semicolon before the line to comment it out, and copy and paste the following code in the next line. Change “BLUEHOST-USERNAME” to your username.

extension_dir = "/home/BLUEHOST-USERNAME/modules"

Note that this step will knock out any other modules which are loaded from the default extension_dir path. I haven’t found a way to load APC otherwise (as a zend_extension, for example).

Next, search for “Windows Extensions” in your php.ini file. You will see a list of directives preceded by semicolons. Copy and paste the following set of parameters above the “Windows Extensions” line to configure APC.

Finally, save and upload your php.ini file back to your public_html directory. You’ll need to restart your FastCGI engine, so log into your CPanel, find “Process Manager” under the “Advanced” header, and kill off any /ramdisk/bin/fcgiphp5 processes. Once they’re dead, navigate back to your site (this will automatically “restart” the FastCGI process and incorporate APC into the engine).

To verify that APC is indeed loaded, create a phpinfo file, and navigate to it via a web browser. Scroll down and look for an APC section.

If you’re a WordPress user, be sure to download the APC Object Cache Backend to your computer, extract it, and move the object-cache.php file to your server directly under the /wp-content/directory (note, this should not be installed like a regular plugin since those are installed under /wp-content/plugins/)

Though I haven’t run any official benchmarks comparing APC to XCache and eAccelerator, the very fact that it’s incorporated into PHP6 and seems to currently have more active development were good enough reasons for me to switch over. 🙂

Previous article
Next article

Related Articles


    • I got to the point of killing the processes and did kill succesfully but didn’t see the apc module in the php_info, I see the extension_dir updated though. I’m using fcgiphp54 btw

  1. Hello; Thanks for your help, i doesn’t work when i switch to PHP 5.4 or 5.3. can you help me please

  2. Rishi: I used your instructions this evening to install APC on blue host this evening with Marc Johnson’s extension path mod. So Kyle it still works…

    Had an issue restarting PHP CGI. Couldn’t find any /ramdisk/bin/fcgiphp5 processes to kill.

    This was solved by a snippet from your other post bout php 5.3 after I added the “AddHandler” line to .htdocs then noticed an error in the log:

    PHP Warning: PHP Startup: apc: Unable to initialize module Module compiled with module API=20060613 PHP compiled with module API=20090626 These options need to match in Unknown on line 0

    This is caused by the module being complied against PHP 5.2 versus running PHP 5.3
    when I commented out the Addhandleer line again it restarted the CGI and APC was working for PHP5.2 I could see graphs etc., using apc.php
    So one way to get PHP to restart is to put that line in then take it out again.
    Not sure how to compile APC for PHP5.3 probably the attribute from .configure
    needs to point somewhere else.
    Also got a compile error that apxs was not recognized but APC still worked in the end.
    Another note for folks with several domains on the same www/
    you need to put the php.ini in the root of the site you are running along with the apc.php

    • Thank you so much for providing your insight, Jonny! While I’ve steered away from opcode caching for now (had some trouble getting the modules compiled for PHP 5.4), I periodically check for updates. 🙂

  3. @Mika, are you using Bluehost?

    Now I’m confused whether this is still applicable on Bluehost or not?

    I’m currently using XCache but would like to try APC on my Bluehost. Do you mind to clarify this, Rishi?

    • Hey Kyle! I no longer use any opcode caching on my sites (just DropBox, Cloudflare, and a makeshift CDN using Google Apps). I’ve written walkthroughs for both APC and XCache, so feel free to experiment at your leisure. I’d love to hear your results. 🙂

  4. Unfortunatelly, this great post just became outdated, I talked to these guys this morning and this is what they answered:

    I apologize for the inconvenience, however in our shared hosting environment APC is not installed because we don’t run mod_php. We have administrators working on a possible implementation in the future but right now it wouldn’t provide any benefit in our current configuration.
    Looks like we just dont allow it anymore


    • Hello Mika!
      If you’re still interested in using a PHP accelerator, I’m using XCache with no problem. You can follow my walkthrough here: Install XCache on BlueHost

  5. you said “Note that this step will knock out any other modules which are loaded from the default extension_dir path. I haven’t found a way to load APC otherwise (as a zend_extension, for example).”

    Use relative path:

    …and then no need to change extension_dir

      • You should ask Bluehost with a support ticket and they’ll give you the instructions. Althought I’m having problems with the APC uptime, it’s always 0 minutes, so… for some reason I don’t understand it’s restarting every minute…


Please enter your comment!
Please enter your name here

Try EchoTools - my free, iOS ultrasonography reference application!

Latest Articles