작은숲:위키노트/APCu
PHP 5.5 버전 이후 APC의 기능이 PHP OPcache와 합쳐지고, 객체 캐싱을 비롯한 나머지 부분은 APCu 확장 기능으로 바뀌었다. 미디어위키 등의 웹 애플리케이션에서 객체 캐싱을 위해 APC 함수를 사용한다면 APCu 확장 기능을 설치하고, APCu_bc 확장 기능도 설치해야 한다. APCu_bc 확장 기능은 APC에 대한 하위 호환성을 유지하기 위한 확장 기능이다.
내려받기
https://pecl.php.net/package/APCu 페이지와 https://pecl.php.net/package/apcu_bc 페이지에서 현재 버전을 확인하고 적당한 버전을 내려받는다. 2016년 3월 11일 현재, APCu 확장 기능의 최신 안정 버전은 5.1.3이고, APCu_bc 확장 기능의 최신 안정 버전은 1.0.3이다.
# wget https://pecl.php.net/get/apcu-5.1.3.tgz
--2016-03-11 20:07:16-- https://pecl.php.net/get/apcu-5.1.3.tgz
Resolving pecl.php.net... 104.236.228.160
Connecting to pecl.php.net|104.236.228.160|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 108422 (106K) [application/octet-stream]
Saving to: `apcu-5.1.3.tgz'
100%[==========================================================>] 108,422 78.0K/s in 1.4s
2016-03-11 20:07:19 (78.0 KB/s) - `apcu-5.1.3.tgz' saved [108422/108422]
# tar zxvf apcu-5.1.3.tgz
package.xml
apcu-5.1.3/tests/023-2.inc
apcu-5.1.3/tests/024.phpt
...
apcu-5.1.3/README.md
apcu-5.1.3/TECHNOTES.txt
apcu-5.1.3/TODO
# wget https://pecl.php.net/get/apcu_bc-1.0.3.tgz
--2016-03-11 22:34:20-- https://pecl.php.net/get/apcu_bc-1.0.3.tgz
Resolving pecl.php.net... 104.236.228.160
Connecting to pecl.php.net|104.236.228.160|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7245 (7.1K) [application/octet-stream]
Saving to: `apcu_bc-1.0.3.tgz'
100%[==========================================================>] 7,245 --.-K/s in 0s
2016-03-11 22:34:26 (106 MB/s) - `apcu_bc-1.0.3.tgz' saved [7245/7245]
# tar zxvf apcu_bc-1.0.3.tgz
...
apcu_bc-1.0.3/config.m4
apcu_bc-1.0.3/config.w32
apcu_bc-1.0.3/php_apc.h
apcu_bc-1.0.3/php_apc.c
apcu_bc-1.0.3/README.md
apcu_bc-1.0.3/LICENSE
APCu 확장 기능 설치
Yum으로 PHP를 설치한 경우가 아니라면 서버에 설치된 phpize의 경로를 찾아 실행한다. PHP가 설치된 경로가 환경변수에 PATH로 설정되어 있다면 그냥 phpize를 실행하면 된다.
# cd apcu-5.1.3
# /usr/local/php70/bin/phpize
Configuring for:
PHP Api Version: 20151012
Zend Module Api No: 20151012
Zend Extension Api No: 320151012
./configure를 실행할 때도 PHP 설치 경로가 PATH에 설정되지 않았다면 --with-php-config 옵션을 설정해야 한다.
# ./configure --with-php-config=/usr/local/php70/bin/php-config
...
creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
# make
...
----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/src/apcu-5.1.3/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 the `LD_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.
Don't forget to run 'make test'.
# make test
...
=====================================================================
TEST RESULT SUMMARY
---------------------------------------------------------------------
Exts skipped : 0
Exts tested : 50
---------------------------------------------------------------------
Number of tests : 27 27
Tests skipped : 0 ( 0.0%) --------
Tests warned : 0 ( 0.0%) ( 0.0%)
Tests failed : 0 ( 0.0%) ( 0.0%)
Expected fail : 0 ( 0.0%) ( 0.0%)
Tests passed : 27 (100.0%) (100.0%)
---------------------------------------------------------------------
Time taken : 3 seconds
=====================================================================
This report can be automatically sent to the PHP QA team at
http://qa.php.net/reports and http://news.php.net/php.qa.reports
This gives us a better understanding of PHP's behavior.
If you don't want to send the report immediately you can choose
option "s" to save it. You can then email it to qa-reports@lists.php.net later.
Do you want to send this report now? [Yns]:
# make install
Installing shared extensions: /usr/local/php70/lib/php/extensions/no-debug-non-zts-20151012/
Installing header files: /usr/local/php70/include/php/
APCu_bc 확장 기능 설치
# cd ../apcu_bc-1.0.3
# /usr/local/php70/bin/phpize
Configuring for:
PHP Api Version: 20151012
Zend Module Api No: 20151012
Zend Extension Api No: 320151012
# ./configure --enable-apc --with-php-config=/usr/local/php70/bin/php-config
...
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
# 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/php70/lib/php/extensions/no-debug-non-zts-20151012/
PHP 설정 추가
설치된 위치를 확인한 후 PHP 설정 파일 php.ini에 아래 내용을 추가한다. 반드시 apcu.so를 먼저 올려야 한다.
extension=apcu.so
extension=apc.so
[apc]
apc.enabled = On
apc.shm_size = 256M
apc.ttl = 7200
apc.enable_cli = On
apc.gc_ttl = 3600
apc.entries_hint = 4096
apc.slam_defense = On
apc.serializer = php
이제 웹 서버나 작은숲:위키노트/PHP-FPM을 다시 시작한 후 phpinfo에서 확장 기능이 제대로 올라왔는지 확인한다.
# service php7-fpm restart
# /usr/bin/php7 -m | grep apc
apc
apcu
같이 보기
참고
- (영어) PECL: APCu Package
- (영어) PECL: apcu_bc Package
- (영어) GitHub: APCu Project
- (영어) GitHub: APCu_bc Project
- (영어) PHP: APCu Manual
- (영어) How to Install the PHP APCu Extension
| PHP 7.0 | |
|---|---|
| PHP 5.6 | |
| PHP 5.5 | |
| 확장 기능 | |
| 활용 | |
| 소프트웨어 | |