---
title: "Install APC for PHP"
description: "Of note, APC has been discontinued. Instead, check out the NGINX Cache Manager for your PHP caching needs. In this guide I'll cover how to install APC for PHP which is the Alternative PHP Cache that..."
url: https://www.inmotionhosting.com/support/website/install-apc-for-php/
date: 2014-05-08
modified: 2021-08-16
author: "InMotion Hosting Contributor"
categories: ["Website"]
type: post
lang: en
---

# Install APC for PHP

Of note, APC has been discontinued. Instead, check out the [NGINX Cache Manager](https://www.inmotionhosting.com/support/product-guides/wordpress-hosting/nginx-cache-manager/) for your PHP caching needs.

In this guide I’ll cover how to install APC for PHP which is the Alternative PHP Cache that can help speed up your PHP powered website. You can read our [speed up PHP with APC](/support/website/speed-up-php-with-apc/) guide for more info on how APC works.

After you install APC, you will want to learn how to [view and clear the APC cache](/support/website/view-and-clear-php-apc-cache/). That way you can keep tabs on what APC is caching, and how effective it might be working for your website.

## Installing APC for PHP

You’ll need to have root access on either a VPS or dedicated server in order to install APC for PHP. You also will need to be running either the **FastCGI** or **DSO** [PHP handlers](/support/website/choosing-the-best-php-handler/) for APC to function properly.

1. [Login to your server via SSH](/support/server/ssh/how-to-login-ssh/) with your [root SSH access](/support/server/ssh/standard-vs-root-access/).
2. Change directories with the following command: cd /usr/local/src
3. Get the source code for APC with the following code: wget https://pecl.php.net/get/APC-3.1.13.tgz
4. Now extract the APC archive with this command: tar xvzf APC-3.1.13.tgz
5. Navigate into the extracted folder: cd APC-3.1.13
6. Now run the following command to configure APC to your PHP environment: phpize You should get something like this back: Configuring for: PHP Api Version: 20090626 Zend Module Api No: 20090626 Zend Extension Api No: 220090626
7. Next configure the source code to run on your server with this command: ./configure You’ll see a lot of text scrolling by looking like this: checking for grep that handles long lines and -e… /bin/grep checking for egrep… /bin/grep -E checking for a sed that does not truncate output… /bin/sed checking for cc… cc ………. creating libtool appending configuration tag “CXX” to libtool configure: creating ./config.status config.status: creating config.h
8. Now you’ll want to actually create the APC software with this command: make Again you’ll see a lot of text scrolling by looking like: /bin/sh /usr/local/src/APC-3.1.13/libtool –mode=compile cc -I. -I/usr/local/src/APC-3.1.13 -DPHP_ATOM_INC -I/usr/local/src/APC-3.1.13/include -I/usr/local/src/APC-3.1.13/main -I/usr/local/src/APC-3.1.13 -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/APC-3.1.13/apc.c -o apc.lo mkdir .libs ……… ———————————————————————- Libraries have been installed in: /usr/local/src/APC-3.1.13/modules Build complete.
9. Locate the extension_dir for PHP with this command: grep extension_dir /usr/local/lib/php.ini You should get back a path that looks something like: extension_dir = “/usr/local/lib/php/extensions/no-debug-non-zts-20090626”
10. Run this command to copy the APC Apache module (apc.so) to your PHP extension directory: cp -frp modules/apc.so /usr/local/lib/php/extensions/no-debug-non-zts-20090626/
11. Edit your php.ini file with your favorite text editor after making a backup: cp -frp /usr/local/lib/php.ini /usr/local/lib/php.ini-BAK vi /usr/local/lib/php.ini Add these APC settings to the very bottom and save the php.ini file: extension=apc.so apc.enabled=1 apc.shm_size=128 apc.cache_by_default=”1″ apc.shm_segments=”1″ apc.ttl=”7200″ apc.user_ttl=”7200″ apc.gc_ttl=”1800″ apc.optimization = 0 apc.num_files_hint=”1024″ apc.use_request_time = 1 apc.mmap_file_mask=”/tmp/apc.XXXXXX” apc.enable_cli=”0″ apc.slam_defense=”0″ apc.file_update_protection=”2″ apc.max_file_size=”1M” apc.stat=”1″ apc.write_lock=”1″ apc.report_autofilter=”0″ apc.include_once_override=”0″ apc.rfc1867=”0″ apc.rfc1867_prefix=”upload_” apc.rfc1867_name=”APC_UPLOAD_PROGRESS” apc.rfc1867_freq=”0″ apc.localcache=”0″ apc.localcache.size=”512″ apc.coredump_unmap=”0″
12. Place the following code inside a info.php script on your site: <?php phpinfo(); ?>
13. Access that script on your site such as https://example.com/info.php. Look for the apc section: ![apc enabled in phpinfo](https://www.inmotionhosting.com/support/images/stories/php/apc/apc-enabled-in-phpinfo.png) If you don’t see an **apc** section yet you might need to restart Apache with this command: service httpd restart

Congratulations! You should now have successfully installed APC for PHP!
