CentOS APC 설치


24px-Disambig_grey.svg.png 다른 뜻에 대해서는 우분투 APC 설치 문서를 참조하십시오.
CentOS Alternative PHP Cache 설치
CentOS APC 설치

사전작업

pecl install로 설치할 예정인데, 정상적으로 설치하기 위해서는 pecl, gcc, phpize, make 명령어를 사용할 수 있는 환경이 되어야 한다.

한방 설치 명령어
yum install php-pear gcc php-devel make pcre-devel
설치확인
[root@zetawiki ~]# pecl version
PEAR Version: 1.4.9
PHP Version: 5.2.10
Zend Engine Version: 2.2.0
Running on: Linux jmnote.com 2.6.18-274.3.1.el5xen #1 SMP Tue Sep 6 20:57:11 EDT 2011 x86_64
[root@zetawiki ~]# gcc
gcc: no input files
[root@zetawiki ~]# phpize
Cannot find config.m4. 
Make sure that you run '/usr/bin/phpize' in the top level syntaxhighlight directory of the module
[root@zetawiki ~]# make 
make: *** No targets specified and no makefile found.  Stop.
[root@zetawiki ~]# yum list installed php-pear gcc php-devel make pcre-devel
... (생략)
Installed Packages
gcc.x86_64                                                       4.4.7-3.el6                                                  @base
make.x86_64                                                      1:3.81-20.el6                                                @base
pcre-devel.x86_64                                                7.8-6.el6                                                    @base
php-devel.x86_64                                                 5.3.3-22.el6                                                 @base
php-pear.noarch                                                  1:1.9.4-4.el6                                                @base
→ 정상적으로 설치되어 있다면 위와 같이 나온다.

APC 설치

명령어
pecl install apc
실행예시
[root@zetawiki ~]# pecl install apc
downloading APC-3.1.13.tgz ...
Starting to download APC-3.1.13.tgz (171,591 bytes)
.....................................done: 171,591 bytes
55 syntaxhighlight files, building
running: phpize
Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
Zend Extension Api No:   220090626
Enable internal debugging in APC [no] :

Enter 키 입력.

Enable per request file info about files used from the APC cache [no] : 
Enable spin locks (EXPERIMENTAL) [no] : 
Enable memory protection (EXPERIMENTAL) [no] : 
Enable pthread mutexes (default) [no] : 
Enable pthread read/write locks (EXPERIMENTAL) [yes] :

모두 Enter 키 입력

... (생략)
Build process completed successfully
Installing '/usr/lib64/php/modules/apc.so'
Installing '/usr/include/php/ext/apc/apc_serializer.h'
install ok: channel://pecl.php.net/APC-3.1.13
configuration option "php_ini" is not set to php.ini location
You should add "extension=apc.so" to php.ini
→ 정상적으로 빌드되었으며, /usr/lib64/php/modules/apc.so 이 생성되었다.
php.iniextension=apc.so를 추가해야 한다고 알려준다.

PHP와 APC 연동

VirtualHost 없는 경우

[root@zetawiki ~]# php -m | grep apc
→ 연동 안됨
  • php.ini의 맨아래에 다음 내용을 추가
[apc]
extension=apc.so
[root@zetawiki ~]# php -m | grep apc
apc
→ 연동됨

VirtualHost 있는 경우

httpd.conf에서 VirtualHost를 사용하는 경우에는 정상작동을 위해 조금 다른 설정이 필요하다.[1]

  • php.ini의 맨아래에 다음 내용을 추가
[apc]
extension=apc.so
apc.cache_by_default=0
→ 일단 apc 캐시를 사용하지 않도록 설정
  • 캐시되기 원하는 VirtualHost의 웹루트폴더의 .htaccess 파일에 다음 내용 추가
php_flag apc.cache_by_default On

아파치 재시작

[root@zetawiki ~]# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]

같이 보기

주석

  1. 여러 VirtualHost에 적용이 되지 않는 모양이다.