phpでpearをインストールする
現在構築中のサービスでpearが必要になったので、pearをインストールしました。
まずはpearインストールのためのレポジトリをダウンロードします。
1 2 3 4 5 6 7 8 9 10 11 12 13 |
# wget http://pear.php.net/go-pear.phar --2017-09-24 00:22:29-- http://pear.php.net/go-pear.phar Resolving pear.php.net... 109.203.101.62 Connecting to pear.php.net|109.203.101.62|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 3597255 (3.4M) [text/plain] Saving to: `go-pear.phar' 100%[=================================================================================>] 3,597,255 841K/s in 4.2s 2017-09-24 00:22:34 (841 KB/s) - `go-pear.phar' saved [3597255/3597255] # |
続いて、phpコマンドでインストールします。
「1-12, ‘all’ or Enter to continue: 」の聞かれるので、デフォルト設定でよければそのままENTERを押します。
また、途中で「Would you like to alter php.ini </etc/php.ini>? [Y/n] :」と聞かれるので「y」で応答します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# php go-pear.phar Below is a suggested file layout for your new PEAR installation. To change individual locations, type the number in front of the directory. Type 'all' to change all of them or simply press Enter to accept these locations. 1. Installation base ($prefix) : /usr 2. Temporary directory for processing : /tmp/pear/install 3. Temporary directory for downloads : /tmp/pear/install 4. Binaries directory : /bin 5. PHP code directory ($php_dir) : /share/pear 6. Documentation directory : /docs 7. Data directory : /data 8. User-modifiable configuration files directory : /cfg 9. Public Web Files directory : /www 10. System manual pages directory : /man 11. Tests directory : /tests 12. Name of configuration file : /etc/pear.conf 1-12, 'all' or Enter to continue: Beginning install... Configuration written to /etc/pear.conf... Initialized registry... Preparing to install... installing phar:///root/go-pear.phar/PEAR/go-pear-tarballs/Archive_Tar-1.4.3.tar... installing phar:///root/go-pear.phar/PEAR/go-pear-tarballs/Console_Getopt-1.4.1.tar... installing phar:///root/go-pear.phar/PEAR/go-pear-tarballs/PEAR-1.10.5.tar... installing phar:///root/go-pear.phar/PEAR/go-pear-tarballs/Structures_Graph-1.1.1.tar... installing phar:///root/go-pear.phar/PEAR/go-pear-tarballs/XML_Util-1.4.2.tar... install ok: channel://pear.php.net/Archive_Tar-1.4.3 install ok: channel://pear.php.net/Console_Getopt-1.4.1 install ok: channel://pear.php.net/Structures_Graph-1.1.1 install ok: channel://pear.php.net/XML_Util-1.4.2 install ok: channel://pear.php.net/PEAR-1.10.5 PEAR: Optional feature webinstaller available (PEAR's web-based installer) PEAR: Optional feature gtkinstaller available (PEAR's PHP-GTK-based installer) PEAR: Optional feature gtk2installer available (PEAR's PHP-GTK2-based installer) PEAR: To install optional features use "pear install pear/PEAR#featurename" ****************************************************************************** WARNING! The include_path defined in the currently used php.ini does not contain the PEAR PHP directory you just specified: </share/pear> If the specified directory is also not in the include_path used by your scripts, you will have problems getting any PEAR packages working. Would you like to alter php.ini </etc/php.ini>? [Y/n] : y php.ini </etc/php.ini> include_path updated. Current include path : .:/usr/share/pear:/usr/share/php Configured directory : /share/pear Currently used php.ini (guess) : /etc/php.ini Press Enter to continue: The 'pear' command is now at your service at /bin/pear ** The 'pear' command is not currently in your PATH, so you need to ** use '/bin/pear' until you have added ** '/bin' to your PATH environment variable. Run it without parameters to see the available actions, try 'pear list' to see what packages are installed, or 'pear help' for help. For more information about PEAR, see: http://pear.php.net/faq.php http://pear.php.net/manual/ Thanks for using go-pear! # |
/etc/php.iniへpearのインストール時に変更を加えていますが、以下のようにpearへのpathが追加されています。
1 2 3 4 5 6 7 |
# tail -5 /etc/php.ini ;***** Added by go-pear include_path=".:/share/pear" ;***** # |
これがあれば、以下のようにphpファイル内でpearのpathを意識せずに利用できます。
1 2 |
<?php require_once 'PEAR.php'; |
php.iniが変更されているので、pearインストール完了後、php-fpmを再起動しましょう!
1 2 3 4 |
# service php-fpm restart Stopping php-fpm: [ OK ] Starting php-fpm: [ OK ] # |