작은숲:위키노트/APC
APC(Alternative PHP Cache) 모듈. 이름 그대로 PHP의 속도 향상을 위해 사용하는 캐시 모듈. 미디어위키에서는 속도 향상을 위해 APC나 XCache 등을 설치할 것을 권장한다.
APC 모듈의 소스 컴파일 후 설치
소스 컴파일 해서 설치하기 위해서는 php-devel 패키지가 설치되어 있어야 한다.
# yum install php-devel
PECL의 APC 패키지 페이지에 가서 최신 버전을 받아온다. 2016년 2월 현재, 최신 버전은 3.1.13이다.
# wget http://pecl.php.net/get/APC-3.1.13.tgz
--2016-02-13 00:37:11-- http://pecl.php.net/get/APC-3.1.13.tgz
Resolving pecl.php.net... 104.236.228.160
Connecting to pecl.php.net|104.236.228.160|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 171591 (168K) [application/octet-stream]
Saving to: `APC-3.1.13.tgz'
100%[==========================================================>] 171,591 136K/s in 1.2s
2016-02-13 00:37:13 (136 KB/s) - `APC-3.1.13.tgz' saved [171591/171591]
# tar zxvf APC-3.1.13.tgz
...
APC-3.1.13/apc_rfc1867.c
APC-3.1.13/apc_serializer.h
APC-3.1.13/apc.php
# cd APC-3.1.13
소스를 다운로드 한 후 압축을 풀고 소스 디렉토리에 들어가서, phpize와 configure를 실행한다. PHP를 소스 컴파일해서 설치했기 때문에 디렉토리 경로가 패키지로 설치했을 때와는 다르다. 이런 경우 configure를 실행할 때 --with-php-config 옵션을 줘서 실행시켜야 제대로 실행된다.
# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626
# ./configure --with-php-config=/usr/local/php/bin/php-config
...
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
configure가 제대로 끝나면 make 해서 컴파일 한 후 make install 해서 apc.so 파일을 설치한다.
# make
...
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Build complete.
Don't forget to run 'make test'.
# make install
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-zts-20090626/
Installing header files: /usr/local/php/include/php/
# ls /usr/local/php/lib/php/extensions/no-debug-zts-20090626/
apc.so
설치가 제대로 끝나면 php.ini에 apc.so를 추가한다.
php.ini
...
[apc]
extension = "/usr/local/php/lib/php/extensions/no-debug-zts-20090626/apc.so"
물론 위에서 경로는 apc.so가 설치된 경로를 지정해야 한다.
이제 아파치를 재기동하면 phpinfo()에서 APC 모듈이 올라온 것을 확인할 수 있다.