"CentOS APC 설치"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
 
(사용자 3명의 중간 판 23개는 보이지 않습니다)
1번째 줄: 1번째 줄:
;APC
{{다른뜻|우분투 APC 설치}}
 
;CentOS Alternative PHP Cache 설치
==주의사항==
;CentOS APC 설치
※ [[VirtualHost 사용 환경]]에서는 APC가 정상 작동하지 않는다.
한 서버에서 여러 개의 도메인을 사용하는 등의 목적으로 [[httpd.conf]]에 VirtualHost를 설정하는데 제대로 작동하지 않았다.<ref>아무 오류메시지가 없는데 브라우저로 접속하면 로딩만 계속하는 현상이 나타났다.</ref>


==사전작업==
==사전작업==
12번째 줄: 10번째 줄:
*[[php-devel 설치]] (설치여부는 명령어 <code>phpize</code>로 확인)
*[[php-devel 설치]] (설치여부는 명령어 <code>phpize</code>로 확인)
*[[make 설치]] (설치여부는 명령어 <code>make</code>로 확인)
*[[make 설치]] (설치여부는 명령어 <code>make</code>로 확인)
*[[pcre-devel 설치]]
;한방 설치 명령어
<syntaxhighlight lang='bash'>
yum install php-pear gcc php-devel make pcre-devel
</syntaxhighlight>


;설치확인
;설치확인
<source lang='dos'>
<syntaxhighlight lang='console'>
[root@jmnote ~]# pecl version
[root@zetawiki ~]# pecl version
PEAR Version: 1.4.9
PEAR Version: 1.4.9
PHP Version: 5.2.10
PHP Version: 5.2.10
Zend Engine Version: 2.2.0
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
Running on: Linux jmnote.com 2.6.18-274.3.1.el5xen #1 SMP Tue Sep 6 20:57:11 EDT 2011 x86_64
</source>
</syntaxhighlight>
<source lang='dos'>
<syntaxhighlight lang='console'>
[root@jmnote ~]# gcc
[root@zetawiki ~]# gcc
gcc: no input files
gcc: no input files
</source>
</syntaxhighlight>
<source lang='dos'>
<syntaxhighlight lang='console'>
[root@jmnote ~]# phpize
[root@zetawiki ~]# phpize
Cannot find config.m4.  
Cannot find config.m4.  
Make sure that you run '/usr/bin/phpize' in the top level source directory of the module
Make sure that you run '/usr/bin/phpize' in the top level syntaxhighlight directory of the module
</source>
</syntaxhighlight>
<source lang='dos'>
<syntaxhighlight lang='console'>
[root@jmnote ~]# make  
[root@zetawiki ~]# make  
make: *** No targets specified and no makefile found.  Stop.
make: *** No targets specified and no makefile found.  Stop.
</source>
</syntaxhighlight>
<syntaxhighlight lang='console'>
[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
</syntaxhighlight>
:→ 정상적으로 설치되어 있다면 위와 같이 나온다.
:→ 정상적으로 설치되어 있다면 위와 같이 나온다.


==APC 설치==
==APC 설치==
;명령어
;명령어
<source lang='bash'>
<syntaxhighlight lang='bash'>
pecl install apc
pecl install apc
</source>
</syntaxhighlight>


;실행예시
;실행예시
<source lang='dos'>
<syntaxhighlight lang='console'>
[root@jmnote ~]# pecl install apc
[root@zetawiki ~]# pecl install apc
downloading APC-3.1.9.tgz ...
downloading APC-3.1.13.tgz ...
Starting to download APC-3.1.9.tgz (155,540 bytes)
Starting to download APC-3.1.13.tgz (171,591 bytes)
.................................done: 155,540 bytes
.....................................done: 171,591 bytes
54 source files, building
55 syntaxhighlight files, building
running: phpize
running: phpize
Configuring for:
Configuring for:
PHP Api Version:        20041225
PHP Api Version:        20090626
Zend Module Api No:      20060613
Zend Module Api No:      20090626
Zend Extension Api No:  220060519
Zend Extension Api No:  220090626
Enable internal debugging in APC [no] :  
Enable internal debugging in APC [no] :  
</source>
</syntaxhighlight>
{{Enter}} 키 입력.
{{Enter}} 키 입력.
<source lang='dos'>
<syntaxhighlight lang='console'>
Enable per request file info about files used from the APC cache [no] :  
Enable per request file info about files used from the APC cache [no] :  
Enable spin locks (EXPERIMENTAL) [no] :  
Enable spin locks (EXPERIMENTAL) [no] :  
Enable memory protection (EXPERIMENTAL) [no] :  
Enable memory protection (EXPERIMENTAL) [no] :  
Enable pthread mutexes (default) [yes] :  
Enable pthread mutexes (default) [no] :  
Enable pthread read/write locks (EXPERIMENTAL) [no] :  
Enable pthread read/write locks (EXPERIMENTAL) [yes] :  
</source>
</syntaxhighlight>
모두 {{Enter}} 키 입력
모두 {{Enter}} 키 입력
<source lang='dos'>
<syntaxhighlight lang='console'>
... (생략)
... (생략)
Build process completed successfully
Build process completed successfully
Installing '/var/tmp/pear-build-root/install-APC-3.1.9//usr/include/php/ext/apc/apc_serializer.h'
Installing '/usr/lib64/php/modules/apc.so'
Installing '/var/tmp/pear-build-root/install-APC-3.1.9//usr/lib64/php/modules/apc.so'
Installing '/usr/include/php/ext/apc/apc_serializer.h'
install ok: channel://pecl.php.net/APC-3.1.9
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
You should add "extension=apc.so" to php.ini
</source>
</syntaxhighlight>
:→ 정상적으로 빌드되었으며, /usr/lib64/php/modules/apc.so 이 생성되었다.
:→ 정상적으로 빌드되었으며, /usr/lib64/php/modules/apc.so 이 생성되었다.
:→ [[php.ini]]에 <code>extension=apc.so</code>를 추가해야 한다고 알려준다.
:→ [[php.ini]]에 <code>extension=apc.so</code>를 추가해야 한다고 알려준다.


==PHP와 APC 연동==
==PHP와 APC 연동==
위에서는 php.ini에 추가하라고 했지만, /etc/php.d에 별도의 파일로 추가해도 된다.
===VirtualHost 없는 경우===
추가 후에는 아파치를 재시작해야 한다.
<syntaxhighlight lang='console'>
[root@zetawiki ~]# php -m | grep apc
</syntaxhighlight>
:→ 연동 안됨
 
*[[php.ini]]의 맨아래에 다음 내용을 추가
<syntaxhighlight lang='properties'>
[apc]
extension=apc.so
</syntaxhighlight>
 
<syntaxhighlight lang='console'>
[root@zetawiki ~]# php -m | grep apc
apc
</syntaxhighlight>
:→ 연동됨
 
===VirtualHost 있는 경우===
[[httpd.conf]]에서 VirtualHost를 사용하는 경우에는 정상작동을 위해 조금 다른 설정이 필요하다.<ref>여러 VirtualHost에 적용이 되지 않는 모양이다.</ref>


;명령어
*php.ini의 맨아래에 다음 내용을 추가
<source lang='bash'>
<syntaxhighlight lang='properties'>
echo 'extension=apc.so' > /etc/php.d/apc.ini
[apc]
service httpd restart
extension=apc.so
</source>
apc.cache_by_default=0
</syntaxhighlight>
:→ 일단 apc 캐시를 사용하지 않도록 설정
 
*캐시되기 원하는 VirtualHost의 웹루트폴더의 .htaccess 파일에 다음 내용 추가
<syntaxhighlight lang='php'>
php_flag apc.cache_by_default On
</syntaxhighlight>


;실행예시
==아파치 재시작==
<source lang='dos'>
<syntaxhighlight lang='console'>
[root@jmnote ~]# echo 'extension=apc.so' > /etc/php.d/apc.ini
[root@zetawiki ~]# service httpd restart
[root@jmnote ~]# service httpd restart
Stopping httpd:                                            [  OK  ]
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==
99번째 줄: 138번째 줄:
*[[ERR_EMPTY_RESPONSE]]
*[[ERR_EMPTY_RESPONSE]]
*[[미디어위키 성능 개선]]
*[[미디어위키 성능 개선]]
*[[아파치 연동 모듈 확인]]
*[[APC]]
==주석==
<references/>


[[분류: PHP]]
[[분류: PHP]]
[[분류: 캐시]]
[[분류: APC]]

2020년 11월 2일 (월) 02:34 기준 최신판

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

1 사전작업[ | ]

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
→ 정상적으로 설치되어 있다면 위와 같이 나온다.

2 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를 추가해야 한다고 알려준다.

3 PHP와 APC 연동[ | ]

3.1 VirtualHost 없는 경우[ | ]

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

3.2 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

4 아파치 재시작[ | ]

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

5 같이 보기[ | ]

6 주석[ | ]

  1. 여러 VirtualHost에 적용이 되지 않는 모양이다.
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}