PHP 통합 · 1 min read · Oct 24, 2025

PHP5에 APC (Alternative PHP Cache) 통합하기 (Debian Etch & Apache2)

PHP5에 APC (Alternative PHP Cache) 통합하기 (Debian Etch & Apache2)

버전 1.0
저자: Falko Timme

이 가이드는 Debian Etch 시스템에서 PHP5에 APC (Alternative PHP Cache)를 통합하는 방법을 설명합니다 (Apache2와 함께). APC는 PHP 중간 코드를 캐싱하고 최적화하기 위한 무료 오픈 PHP opcode 캐셔입니다. ** eAccelerator 및 XCache와 같은 다른 PHP opcode 캐셔와 유사합니다.

이것이 당신에게 작동할 것이라는 보장은 하지 않습니다!

1 사전 참고

저는 Apache2와 PHP5가 이미 설치되어 작동 중인 IP 주소 192.168.0.100의 Debian Etch 서버에서 이것을 테스트했습니다. 이 튜토리얼에서는 시연 목적으로 Apache의 기본 문서 루트 /var/www를 사용할 것입니다. 물론 다른 vhost를 사용할 수도 있지만, 이 튜토리얼에서 사용하는 info.php 파일의 경로를 조정해야 할 수도 있습니다.

2 PHP5의 현재 상태 확인

먼저 APC를 설치하기 전에 PHP5 설치에 대해 알아봅시다. 이를 위해 문서 루트 /var/www에 info.php 파일을 생성합니다:

vi /var/www/info.php

| |

그 후, 브라우저에서 해당 파일을 호출합니다: http://192.168.0.100/info.php

보시다시피, PHP 5.2.0이 설치되어 있습니다…

… 하지만 페이지 어디에도 APC가 언급되어 있지 않습니다:

3 APC 설치

APC는 PECL을 사용하여 설치할 수 있는 PHP 확장입니다. PECL은 php-pear 패키지와 함께 제공되므로 지금 설치합니다:

apt-get install php-pear

또한 PECL이 APC를 빌드할 수 있도록 몇 가지 APC 종속성을 설치해야 합니다:

apt-get install php5-dev apache2-prefork-dev build-essential

모든 종속성이 설치되었으므로 다음과 같이 APC를 설치할 수 있습니다:

pecl install apc

server2:~# pecl install apc
downloading APC-3.0.17.tgz …
Starting to download APC-3.0.17.tgz (116,058 bytes)
…………………….done: 116,058 bytes
47 source files, building
running: phpize
Configuring for:
PHP Api Version:         20041225
Zend Module Api No:      20060613
Zend Extension Api No:   220060519
Use apxs to set compile flags (if using APC with Apache)? [yes] : <– ENTER

[…]

———————————————————————-
Libraries have been installed in:
/var/tmp/pear-build-root/APC-3.0.17/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the -LLIBDIR' flag during linking and do at least one of the following: - add LIBDIR to theLD_LIBRARY_PATH’ environment variable
during execution
- add LIBDIR to the LD_RUN_PATH' environment variable during linking - use the-Wl,–rpath -Wl,LIBDIR’ linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf’

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
———————————————————————-

Build complete.
(It is safe to ignore warnings about tempnam and tmpnam).

running: make INSTALL_ROOT=”/var/tmp/pear-build-root/install-APC-3.0.17” install
Installing shared extensions:     /var/tmp/pear-build-root/install-APC-3.0.17/usr/lib/php5/20060613+lfs/
running: find ”/var/tmp/pear-build-root/install-APC-3.0.17” -ls
998152    4 drwxr-xr-x   3 root     root         4096 Mar 28 15:23 /var/tmp/pear-build-root/install-APC-3.0.17
998214    4 drwxr-xr-x   3 root     root         4096 Mar 28 15:23 /var/tmp/pear-build-root/install-APC-3.0.17/usr
998215    4 drwxr-xr-x   3 root     root         4096 Mar 28 15:23 /var/tmp/pear-build-root/install-APC-3.0.17/usr/lib
998216    4 drwxr-xr-x   3 root     root         4096 Mar 28 15:23 /var/tmp/pear-build-root/install-APC-3.0.17/usr/lib/php5
998217    4 drwxr-xr-x   2 root     root         4096 Mar 28 15:23 /var/tmp/pear-build-root/install-APC-3.0.17/usr/lib/php5/20060613+lfs
998213  416 -rwxr-xr-x   1 root     root       418822 Mar 28 15:23 /var/tmp/pear-build-root/install-APC-3.0.17/usr/lib/php5/20060613+lfs/apc.so

Build process completed successfully
Installing ’/var/tmp/pear-build-root/install-APC-3.0.17//usr/lib/php5/20060613+lfs/apc.so’
install ok: channel://pecl.php.net/APC-3.0.17
You should add ”extension=apc.so” to php.ini
server2:~# 이제 APC가 설치되었으므로 구성 파일 /etc/php5/conf.d/apc.ini를 생성합니다. 최소한 extension=apc.so 라인을 추가해야 하며, 다른 모든 구성 옵션은 선택 사항입니다. http://de2.php.net/manual/en/ref.apc.php에서 사용 가능한 모든 구성 옵션 목록을 찾을 수 있습니다. vi /etc/php5/conf.d/apc.ini | extension=apc.so apc.enabled=1 apc.shm_size=30 | 그게 전부입니다. Apache를 재시작하면 완료됩니다: /etc/init.d/apache2 restart 그 후, 브라우저에서 info.php를 다시 엽니다: http://192.168.0.100/info.php 이제 페이지에 APC가 언급되어 있어 성공적으로 통합되었고 예상대로 작동하고 있음을 알 수 있습니다: ### 4 링크 - APC: http://pecl.php.net/package/APC - PHP: http://www.php.net - Apache: http://httpd.apache.org - Debian: http://www.debian.org

Share: X/Twitter LinkedIn

새 게시물을 받은 편지함에서 받기

스팸은 없습니다. 언제든지 구독 해지 가능합니다.