Alternative PHP Cache
lastmod 2018-08-17created 2015-01-159 edits
APC (Alternative PHP Cache), like eAccelerator and xcache, performs opcode caching.
How to install
- Enable APC ( Alternative PHP Cache ) and makes PHP be fast.
- Install APC (Alternative PHP Cache) in RHEL/CentOS 6/5 & Fedora 20-12
The method below did not work properly in the test environment (CentOS7). <del>
</del>
Install it as follows instead.
sudo yum install php-pear php-devel httpd-devel pcre-devel gcc make
sudo pecl channel-update pecl.php.net
sudo pecl install apc
## 중간에 나오는 질문에 답변한다. (그냥 전부 Enter 해도 된다)
Finally, add the apc configuration and restart the service.
## configuration option "php_ini" is not set to php.ini location
## You should add "extension=apc.so" to php.ini
echo "extension=apc.so" > /etc/php.d/apc.ini
## Restart apache httpd
sudo service httpd restart
Installing APC on MAC OSX
Reference: Installing Alternative PHP Cache (APC) on Mac OS X Lion
Reference: Installing PHP-APC on Ubuntu
- Download the latest PCRE from http://sourceforge.net/projects/pcre/files/latest/download?source=files
- Unzip the file
- cd into the unzipped pcre- directory and then type:
- Next, we can install the APC extension using the normal PECL route:
- Confirm that you have the following line in your php.ini file:
- Restart Apache, if required:
Configuring APC
Without VirtualHost
Add the following to the bottom of php.ini.
With VirtualHost
If httpd.conf uses VirtualHost, a slightly different configuration is needed for it to work properly. Add the following to the bottom of php.ini. (First, configure APC caching to be disabled.)
Then add the following to the .htaccess file in the web root folder of each VirtualHost you want cached.
Or add the following inside the Apache configuration of each VirtualHost you want cached.
Troubleshooting
A summary of fixes for APC-related problems in PHP.
PHP Warning Unable to load dynamic library apc.so
The following warning message may be printed.
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/apc.so' - /usr/lib64/php/modules/apc.so: undefined symbol: zend_new_interned_string in Unknown on line 0
PHP 5.3.3 (cli) (built: Dec 11 2013 03:29:57) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
You need to install the related PHP module. In this case, reinstall the APC module (if it is installed). Install it as follows.