본문으로 바로가기

[CentOS] PHP - APC 설정

category 리눅스/CentOS 2013. 7. 5. 05:23

CentOS 6.4 Minimal에서 PHP의 모듈중에 하나인 APC를 설정하는 방법에 대하여 알아봅니다.

APC 환경설정

vi /etc/php.d/apc.ini

  ; The size of each shared memory segment, with M/G suffix
  apc.shm_size=128M

/usr/share/php-pecl-apc/apc.php 를 복사해서 서비스할 웹폴더의 루트에 저장하고 웹에서 확인.

service httpd configtest

  Syntax OK
service httpd restart

  httpd 를 정지 중:                                          [  OK  ]
  httpd (을)를 시작 중:                                      [  OK  ]

기본적으로 APC를 설치하고 나면 /etc/php.d/apc.ini 파일의 APC cache 설정이 On 되어 있다(1=On, 0=off).

apc.cache_by_default=1

이는 virtualhost를 운영하여 많은 수의 웹사이트를 운영하고 있다면 엄청난 량의 메모리 사용률을 보인다. 그래서 원하는 사이트에만 APC의 사용을 허가하거나 금지해야 한다.

원하는 virtualhost 사이트에만 APC 사용

1) 우선 기본설정을 APC cache를 사용하지 않게 변경한다.

vi /etc/php.d/apc.ini

  apc.cache_by_default=0

2) 캐시되기 원하는 virtualhost의 웹루트폴더의 .htaccess 파일에 아래 내용 추가

php_flag apc.cache_by_default On

혹은 캐쉬되길 원하는 virtualhost의 설정안에 아래와 같이 내용 추가

<IfModule mod_php5.c>
php_flag apc.cache_by_default On
</IfModule>

반대의 경우로 기본으로 APC는 활성화인 상태에서 캐시되지 않길 바라는 virtualhost의 웹사이트에는 php_flag apc.cache_by_default Off와 같이 내용을 수정한다.

APC Cache Virtual Servers with PHP running under FCGld

http://chrisgilligan.com/wordpress/how-to-configure-apc-cache-on-virtual-servers-with-php-running-under-fcgid/


'리눅스 > CentOS' 카테고리의 다른 글

[CentOS] Apache(아파치) 모듈  (1) 2013.07.09
[CentOS] Apache(아파치) 구조  (0) 2013.07.09
[CentOS] Anacron  (0) 2013.07.05
[CentOS] 방화벽 설정 - iptables  (65) 2013.07.01
[CentOS] APM 설치 - yum  (8) 2013.07.01