PECL을 통해 PHP 확장 모듈을 설치하려면 어떻게 하나요?
💡 요약 정리
- PECL은 PHP 확장을 위한 C 기반의 모듈 라이브러리입니다.
- PHP 확장을 설치하려면 PECL을 통해 모듈을 설치한 후, php.ini 파일에 해당 모듈을 등록해야 합니다.
- 모든 설치나 설정은 루트 권한에서 수행하며, Apache 등의 웹서버를 재시작해야 적용됩니다.
1. 설치되어 있는 PHP 확장 모듈 확인
[root@localhost bin]# cd /usr/local/php/bin
[root@localhost bin]# ./pecl list
Installed packages, channel pecl.php.net:
=========================================
Package Version State
imagick 3.0.1 stable
[root@localhost bin]#
2. PECL 확장 모듈 설치
[root@localhost bin]# ./pecl install hash
downloading hash-1.5.tgz ...
Starting to download hash-1.5.tgz (98,809 bytes)
......................done: 98,809 bytes
30 source files, building
WARNING: php_bin /usr/local/php/bin/php appears to have a suffix /bin/php, but config variable php_suffix does not match
running: phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
building in /var/tmp/pear-build-root/hash-1.5
running: /tmp/pear/temp/hash/configure
checking for egrep... grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking for C compiler default output file name... a.out
설치가 완료되면 다음과 같이 출력됩니다.
Build process completed successfully
Installing '/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/hash.so'
Installing '/usr/local/php/include/php/ext/hash/php_hash_snefru.h'
Installing '/usr/local/php/include/php/ext/hash/php_hash_sha.h'
Installing '/usr/local/php/include/php/ext/hash/php_hash.h'
Installing '/usr/local/php/include/php/ext/hash/php_hash_haval.h'
Installing '/usr/local/php/include/php/ext/hash/php_hash_tiger.h'
Installing '/usr/local/php/include/php/ext/hash/php_hash_crc32.h'
Installing '/usr/local/php/include/php/ext/hash/php_hash_ripemd.h'
Installing '/usr/local/php/include/php/ext/hash/php_hash_adler32.h'
Installing '/usr/local/php/include/php/ext/hash/php_hash_md.h'
Installing '/usr/local/php/include/php/ext/hash/php_hash_types.h'
Installing '/usr/local/php/include/php/ext/hash/php_hash_gost.h'
Installing '/usr/local/php/include/php/ext/hash/php_hash_whirlpool.h'
install ok: channel://pecl.php.net/hash-1.5
configuration option "php_ini" is not set to php.ini location
You should add "extension=hash.so" to php.ini
[root@localhost bin]# cd /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/
[root@localhost no-debug-non-zts-20060613]# ls
hash.so imagick.so
[root@localhost no-debug-non-zts-20060613]#
php.ini 파일에 아래 설정을 추가합니다.
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613"
extension=imagick.so
extension=hash.so
설정 후 반드시 Apache 웹서버를 재시작해야 적용됩니다.
3. 설치 가능한 확장 모듈 리스트 출력
[root@localhost bin]# ./pecl list-all
All packages [Channel pecl.php.net]:
====================================
Package Latest Local
pecl/KTaglib 0.2.0 Library to edit audio properties and tags on MPEG and OGG files
pecl/FliteTTS Text to speech voice synthesis for PHP
pecl/radius 1.2.5 Radius client library
pecl/sasl 0.1.0 Cyrus SASL Extension
pecl/PAM 1.0.3 PAM integration
pecl/courierauth 0.1.0 courierauth binding
pecl/krb5 Kerberos authentication and management
pecl/DTrace 1.0.3 A Solaris Dtrace provider
pecl/inclued 0.1.3 Clued-in about your inclueds
pecl/zookeeper 0.2.1 PHP extension for interfacing with Apache ZooKeeper
pecl/augeas 0.6.1 PHP bindings to the Augeas API
pecl/xmms 0.2 Provides functions to interact with xmms
pecl/newt 1.2.6 Extension for RedHat Newt window library
pecl/tvision 0.1 Turbo Vision wrapper
[root@localhost bin]#
검토 후 설치하려는 모듈명을 확인하고, ./pecl install 모듈명 명령어를 사용하여 설치할 수 있습니다.