Alternative PHP Cache
APC(Alternative PHP Cache)는 eAccelerator, xcache 처럼, 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
아래 방법은 테스트환경(CentOS7)에서 정상적으로 작동하지 않았다. <del>
</del>
아래와 같은 방법으로 설치해야 한다.
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 해도 된다)
마지막으로 apc설정을 추가하고 서비스를 재시작한다.
## 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
APC를 MAC OSX에서 설치하는 방법
참조: Installing Alternative PHP Cache (APC) on Mac OS X Lion
참조: 우분투 PHP-APC 설치
- 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:
APC 설정 방법
VirtualHost 없는 경우
php.ini의 맨아래에 다음 내용을 추가하면 된다.
VirtualHost 있는 경우
httpd.conf에서 VirtualHost를 사용하는 경우에는 정상작동을 위해 조금 다른 설정이 필요하다. php.ini의 맨아래에 다음 내용을 추가한다. (일단 APC 캐시를 사용하지 않도록 설정한다.)
그 후, 캐시되기 원하는 VirtualHost의 웹루트폴더의 .htaccess 파일에 다음 내용을 추가한다.
혹은 캐시되길 원하는 VirtualHost 의 아파치설정안에 아래와 같이 내용을 추가한다.
Troubleshooting
PHP의 APC관련 문제점 해결방법에 대하여 정리한다.
PHP Warning Unable to load dynamic library apc.so
아래와 같은 경고 메시지가 출력될 수 있다.
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
관련 PHP 모듈을 설치해야 한다. 이 경우 APC모듈을 (설치되었다면)재설치해야 한다. 아래와 같이 설치하면 된다.