Full-service Internet Marketing & Web Development
Recent Posts

Sponsors
![]() |
How to install APC on Linux / RedHatMike Peters, 06-14-2010 |
APC (Alternative PHP Cache) is an opcode cache for PHP that pre-compiles commonly used PHP scripts to machine-language, speeding up execution.
We previously used eAccelarator which is another opcode cache for PHP. We decided to switch from eAccelarator to APC due to stability issues and the fact that APC was chosen as the best opcode cache engine to be included with PHP6.
In this post, I'll cover the steps to install APC:
1. Type: 'pecl config-set preferred-state stable'
2. Type: 'pecl install apc'
3. When prompted type 'all' to change configuration
4. Type 'no' to change the option
5. Hit the enter key to run the installation script.
6. When complete, open /usr/local/lib/php.ini for editing
7. Comment out all eaccelerator lines if they exist
8. Add the following block:
extension=apc.so
apc.enabled="1"
apc.shm_segments="1"
apc.shm_size="100"
apc.ttl="5"
apc.user_ttl="5"
apc.gc_ttl="5"
apc.file_update_protection="2"
apc.enable_cli="1"
apc.max_file_size="1M"
apc.write-lock="1"
apc.report_autofilter="0"
apc.include_once_override="0"
Additional settings and explanations for each can be found at: http://www.php.net/manual/en/apc.configuration.php
9. Save the file and exit the editor
10. Change the system setting for shared memory as follows:
a. edit /etc/sysctl.conf
b. add this line:
c. the run the following command:
11. Restart FastCGI manager with:
We previously used eAccelarator which is another opcode cache for PHP. We decided to switch from eAccelarator to APC due to stability issues and the fact that APC was chosen as the best opcode cache engine to be included with PHP6.
In this post, I'll cover the steps to install APC:
1. Type: 'pecl config-set preferred-state stable'
2. Type: 'pecl install apc'
3. When prompted type 'all' to change configuration
4. Type 'no' to change the option
5. Hit the enter key to run the installation script.
6. When complete, open /usr/local/lib/php.ini for editing
7. Comment out all eaccelerator lines if they exist
8. Add the following block:
extension=apc.so
apc.enabled="1"
apc.shm_segments="1"
apc.shm_size="100"
apc.ttl="5"
apc.user_ttl="5"
apc.gc_ttl="5"
apc.file_update_protection="2"
apc.enable_cli="1"
apc.max_file_size="1M"
apc.write-lock="1"
apc.report_autofilter="0"
apc.include_once_override="0"
Additional settings and explanations for each can be found at: http://www.php.net/manual/en/apc.configuration.php
9. Save the file and exit the editor
10. Change the system setting for shared memory as follows:
a. edit /etc/sysctl.conf
b. add this line:
kern.ipc.shmmax=134217728
c. the run the following command:
sysctl -w kern.ipc.shmmax=134217728
11. Restart FastCGI manager with:
/usr/local/bin/php-fpm restart
![]() |
Mike Peters, 06-14-2010 |
Important:
If you're installing APC on a machine that has WordPress with APC-Cache turned on, you have to tell APC to avoid caching the wp-cache config file.
Otherwise, WordPress will stop loading, showing a white screen or a PHP fatal error.
Here's how to get APC and WP-Cache playing nicely:
In php.ini in the [apc] section, add:
This tells APC to exclude wp-cache-config.php and wp-cache-config-sample.php
If you're installing APC on a machine that has WordPress with APC-Cache turned on, you have to tell APC to avoid caching the wp-cache config file.
Otherwise, WordPress will stop loading, showing a white screen or a PHP fatal error.
Here's how to get APC and WP-Cache playing nicely:
In php.ini in the [apc] section, add:
apc.filters="wp-cache-config"
This tells APC to exclude wp-cache-config.php and wp-cache-config-sample.php
|
|
Subscribe Now to receive new posts via Email as soon as they come out.
Comments
Post your comments

