InMotion Hosting Support Center

APC or Alternative PHP Cache, is a free open-source opcode (operation code) caching plugin for PHP. With APC caching your PHP script executions can run more efficiently, by cutting down on dynamic PHP executions.

If you already know about APC, you might like to go ahead and skip to our guide on how to install APC.

We also have a guide that covers how to view and clear the APC cache.

In this article, you'll learn how to speed up PHP with APC.

PHP APC cache example

Why would you want to install APC?

PHP is a dynamic scripting language, so every time there is a request for a page, the server must first parse the code in your PHP script in order to generate the resulting HTML code seen by a visitor's web-browser.

PHP is ideal for web pages that have content that is constantly updated, since each visitor gets a fresh copy of the page. So for instance if you have your PHP script pulling data from a database, as soon as there is new data in the database, it will automatically be in the generated HTML code for the next visitor requesting that page as well.

In most cases the need to re-run PHP scripts for data that might not have changed in the first place, can be taxing on the server. By implementing APC you cut down on repeat PHP script executions, skipping the parsing and compiling steps. APC stores the opcode, and that is simply executed each time the script is called again.

What's the difference between APC and other types of caching?

APC for PHP is one of the most widely used PHP opcode caching solutions in use today. You can utilize APC on a VPS  or dedicated server that is running PHP as either DSO or FastCGI. You might want to read about choosing the best PHP handler for your specific needs, and also a more in-depth explanation on what DSO and FastCGI are.

Another common caching module is Memcached, and the main difference between it and APC is that Memcached is distributed and more robust generic caching platform, while APC is specific to PHP. APC is great when you need local caching of objects for your PHP scripts that are relatively small and frequently accessed.

How to install APC

APC is a PECL module that can be loaded into PHP, but because it operates at the server-level it can not be run on our shared hosting servers. If you are on a VPS or dedicated server and are comfortable installing PECL modules, then you can go ahead and install APC yourself.

Or if you prefer our system administration department can setup APC on your server for you. If this is something that you'd like to take advantage of please contact our support department.

Was this article helpful?

Related Questions

Here are a few questions related to this article that our customers have asked:
Installation of Software on dedicated server
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Forum Login

You are NOT logged in. You can still browse our Support Center.

To participate within our Community Support Forum:

n/a Points
2018-10-03 4:02 pm

Hi, if APC is only offered for VPS and above, then what PHP caching solutions are available for shared hosting plans? Thanks.

42,832 Points
2018-10-03 4:46 pm

Thanks for the question about the PHP caching solutions. The one that we have available in our hosting plans is the WordPress Hosting option. The name implies using WordPress, but it provides caching for any site working through the Apache webserver. Check out this explanation of the WordPress optimized stack. Again, ignore the "WordPress" name as it will work for any site running on your webs server. This is a shared hosting solution and it's not that much more expensive. You can see the options here.

n/a Points
2018-02-28 1:48 pm

apc.enable_cli = 1   should not be activated in working environments, only for testing/debugging.

"apc.enable_cli integer

Mostly for testing and debugging. Setting this enables APC for the CLI version of PHP. Under normal circumstances, it is not ideal to create, populate and destroy the APC cache on every CLI request, but for various test scenarios it is useful to be able to enable APC for the CLI version of PHP easily."

42,832 Points
2018-02-28 2:21 pm
Note that APC is not available for installation version 5.6. For more discussion on APC, check out this support forum post.

n/a Points
2017-10-12 4:00 am

Dear Sir,

I would some direction on installing APC on Windows server for improve performance of SuiteCRM.


31,539 Points
2017-10-12 8:48 am
I spent some time looking into this, and it seems like WinCache is more stable than APC on a Windows server environment.

Thank you,
2015-07-13 9:18 am
APC install is simple if you have the right procedure. Unfortunately there is a lot of bad install advice out there on the net! You really need to do it the cPanel/WHM way as others will just FUBAR your install. The tricky part is to get in your [/usr/local/lib/php/extensions/no-debug-non-zts-XXXXXXXX/], otherwise [Home]/usr/local/lib/php.ini will not work.

Your php.ini ([Home]/usr/local/lib/php.ini) should have [extension=""] (without the brackets) where you load your extensions. It will find it in [/usr/local/lib/php/extensions/no-debug-non-zts-XXXXXXXX/] (current one used). As in WHM Home »Service Configuration »PHP Configuration Editor advanced mode Section [CORE ] , Directive [extension], Value [,,]
After this you should be able to restart Apache and use >>Home »Service Configuration »PHP Configuration Editor >> in WHM, in Advanced Mode.
If not them you php.ini should have something like this (values depend on you needs).
; Module Settings ;

apc.enabled = 1
apc.optimization = 0
apc.shm_segments = 1
apc.shm_size = 256M
apc.ttl = 7200
apc.user_ttl = 7200
apc.gc_ttl = 3600
apc.num_files_hint = 1000
apc.user_entries_hint = 1000
apc.mmap_file_mask = "/tmp/apc-LoginName.XXXXXX"
apc.enable_cli = 1
apc.cache_by_default = 1
apc.max_file_size = 2M
apc.stat = 1
See this link
Good day James Niland
n/a Points
2015-04-05 5:26 pm

Thanks for the post going to try and install APC and test it out hope it does good with the caching...

n/a Points
2014-12-28 9:35 pm
give an example of code
n/a Points
2014-12-26 2:10 pm
Give an exemple!
n/a Points
2014-09-12 3:55 am
n/a Points
2014-08-19 2:30 pm
The article is VERY well written. It takes a complex topic and breaks it down so it's easy to understand. I especially like the diagrams.
42,832 Points
2013-09-06 12:12 pm
Hello Tpradebe,

Thanks for the question. As per the last paragraph above, we do not support the installation of APC on our shared servers, but you can either install it yourself or have it installed on our VPS/Dedicated server solutions.

There's a simple shell command to install APC on a VPS or Dedicated server (you have to be logged into the shell): pecl install apc. You can find more information here: How to install APC.

I hope this helps to answer your question.

Arnel C.
2013-09-06 11:44 am
I'm looking for a good hosting with APC pre-installed, do you do that?
2013-03-23 8:54 pm
I would love some direction on installing APC on an Inmotion VPS. Need to speed up some Magento sites.

Post a Comment

Email Address:
Phone Number:

Please note: Your name and comment will be displayed, but we will not show your email address.

15 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?


Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail:
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!