久しぶりなので、状況を確認しながら
必要なもの
apt install phpize php-pecl
PECLの設定状況を確認する
pecl がどこにインストールするか、何処を使うか
$ pecl config-show
設定を確認しておけば迷わない。
Configuration (channel pecl.php.net): ===================================== Auto-discover new Channels auto_discover <not set> Default Channel default_channel pecl.php.net HTTP Proxy Server Address http_proxy <not set> PEAR server [DEPRECATED] master_server pear.php.net Default Channel Mirror preferred_mirror pecl.php.net Remote Configuration File remote_config <not set> PEAR executables directory bin_dir /usr/bin PEAR documentation directory doc_dir /usr/share/php/doc PHP extension directory ext_dir /usr/lib/php5/20131226 PEAR directory php_dir /usr/share/php PEAR Installer cache directory cache_dir /tmp/pear/cache PEAR configuration file cfg_dir /usr/share/php/cfg directory PEAR data directory data_dir /usr/share/php/data PEAR Installer download download_dir /build/php5-5.6.30+dfsg/pear-build-download directory Systems manpage files man_dir /usr/share/man directory PEAR metadata directory metadata_dir <not set> PHP CLI/CGI binary php_bin /usr/bin/php php.ini location php_ini <not set> --program-prefix passed to php_prefix <not set> PHP's ./configure --program-suffix passed to php_suffix <not set> PHP's ./configure PEAR Installer temp directory temp_dir /tmp/pear/temp PEAR test directory test_dir /usr/share/php/test PEAR www files directory www_dir /usr/share/php/htdocs Cache TimeToLive cache_ttl 3600 Preferred Package State preferred_state stable Unix file mask umask 22 Debug Log Level verbose 1 PEAR password (for password <not set> maintainers) Signature Handling Program sig_bin /usr/bin/gpg Signature Key Directory sig_keydir /etc/pear/pearkeys Signature Key Id sig_keyid <not set> Package Signature Type sig_type gpg PEAR username (for username <not set> maintainers) User Configuration File Filename /home/takuya/.pearrc System Configuration File Filename /etc/pear/pear.conf
インストールしたいパッケージを探す
pecl search mongo Retrieving data...0% .Matched packages, channel pecl.php.net: ======================================= Package Stable/(Latest) Local mongo 1.6.14 (stable) MongoDB database driver mongodb 1.1.6 (stable) MongoDB driver for PHP
ビルドの確認には
php_dir
を変更して適当なディレクトリで実験すればOK
インストール
sudo pecl install mongodb
mod_php の設定をリロード
/etc/php5/conf.d/mongodb.ini
コメント書いておくとOK
; 2016-05-02 PECLからインストール extension=mongodb.so
2020-02-06
pecl のコマンドが 7.3, 7.4 で若干変わってたので改編