pearのNet_UserAgent_Mobileをさくらレンタルサーバーにインストール 2009 年 10 月 22 日

まずは、さくらのレンタルサーバ スタンダードにSSHでログインする

Shell
ssh [your account]@[your account].sakura.ne.jp
password:[パスワードを入力]

インストールされてるパッケージを確認

Shell
%pear list
Installed packages, channel pear.php.net:
=========================================
Package              Version State
Archive_Tar          1.3.3   stable
Console_Getopt       1.2.3   stable
DB                   1.7.13  stable
HTML_Template_IT     1.2.1   stable
HTTP                 1.4.1   stable
HTTP_Client          1.2.1   stable
HTTP_Request         1.4.4   stable
MDB2                 2.4.1   stable
MDB2_Driver_mysql    1.4.1   stable
Mail                 1.1.14  stable
Net_SMTP             1.3.2   stable
Net_Socket           1.0.9   stable
Net_URL              1.0.15  stable
Net_UserAgent_Detect 2.5.1   stable
PEAR                 1.8.1   stable
Structures_Graph     1.0.2   stable
XML_Parser           1.3.2   stable
XML_RPC              1.5.1   stable
XML_Util             1.2.1   stable

Net_UserAgent_Mobileが入ってないので、
普通にpearコマンドでインストールしようと思っても、失敗する。

Shell
%pear install -f Net_UserAgent_Mobile
pear.php.net is using a unsupported protocal - This should never happen.
install failed

そこで、homeディレクトリに戻る

Shell
%cd
%pwd
/home/[your account]

pearの設定ファイル.pearrcファイルを新規作成

Shell
%pear config-create /home/[your account] .pearrc
Configuration (channel pear.php.net):
=====================================
Auto-discover new Channels     auto_discover    <not set>
Default Channel                default_channel  pear.php.net
HTTP Proxy Server Address      http_proxy       <not set>
PEAR server [DEPRECATED]       master_server    <not set>
Default Channel Mirror         preferred_mirror <not set>
Remote Configuration File      remote_config    <not set>
PEAR executables directory     bin_dir          /home/[your account]/pear
PEAR documentation directory   doc_dir          /home/[your account]/pear/docs
PHP extension directory        ext_dir          /home/[your account]/pear/ext
PEAR directory                 php_dir          /home/[your account]/pear/php
PEAR Installer cache directory cache_dir        /home/[your account]/pear/cache
PEAR configuration file        cfg_dir          /home/[your account]/pear/cfg
directory
PEAR data directory            data_dir         /home/[your account]/pear/data
PEAR Installer download        download_dir     /home/[your account]/pear/download
directory
PHP CLI/CGI binary             php_bin          <not set>
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         /home/[your account]/pear/temp
PEAR test directory            test_dir         /home/[your account]/pear/tests
PEAR www files directory       www_dir          /home/[your account]/pear/www
Cache TimeToLive               cache_ttl        <not set>
Preferred Package State        preferred_state  <not set>
Unix file mask                 umask            <not set>
Debug Log Level                verbose          <not set>
PEAR password (for             password         <not set>
maintainers)
Signature Handling Program     sig_bin          <not set>
Signature Key Directory        sig_keydir       <not set>
Signature Key Id               sig_keyid        <not set>
Package Signature Type         sig_type         <not set>
PEAR username (for             username         <not set>
maintainers)
User Configuration File        Filename         /home/[your account]/.pearrc
System Configuration File      Filename         #no#system#config#
Successfully created default configuration file "/home/[your account]/.pearrc"

binのパスを設定

Shell
%pear config-set bin_dir /home/[your account]/pear/bin

17行目のset pathに$HOME/pear/binを追記

Shell
%vi .cshrc
17 #set path = (/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin /usr/X11R6/bin $HOME/bin)
18 set path = (/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin /usr/X11R6/bin $HOME/bin $HOME/pear/bin)

あらためてPEARのインストール

Shell
%pear install PEAR
WARNING: channel "pear.php.net" has updated its protocols, use "pear channel-update pear.php.net" to update
downloading PEAR-1.9.0.tgz ...
Starting to download PEAR-1.9.0.tgz (291,634 bytes)
......................................................done: 291,634 bytes
downloading Archive_Tar-1.3.3.tgz ...
Starting to download Archive_Tar-1.3.3.tgz (18,119 bytes)
...done: 18,119 bytes
downloading Structures_Graph-1.0.3.tgz ...
Starting to download Structures_Graph-1.0.3.tgz (30,191 bytes)
...done: 30,191 bytes
downloading Console_Getopt-1.2.3.tgz ...
Starting to download Console_Getopt-1.2.3.tgz (4,011 bytes)
...done: 4,011 bytes
downloading XML_Util-1.2.1.tgz ...
Starting to download XML_Util-1.2.1.tgz (17,729 bytes)
...done: 17,729 bytes
install ok: channel://pear.php.net/Archive_Tar-1.3.3
install ok: channel://pear.php.net/Structures_Graph-1.0.3
install ok: channel://pear.php.net/Console_Getopt-1.2.3
install ok: channel://pear.php.net/XML_Util-1.2.1
install ok: channel://pear.php.net/PEAR-1.9.0
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"

PEARチャンネルアップデート

Shell
%pear channel-update pear.php.net
Updating channel "pear.php.net"
Update of Channel "pear.php.net" succeeded

Net_UserAgent_Mobileインストール

Shell
%pear install -f Net_UserAgent_Mobile
downloading Net_UserAgent_Mobile-1.0.0.tgz ...
Starting to download Net_UserAgent_Mobile-1.0.0.tgz (43,849 bytes)
............done: 43,849 bytes
install ok: channel://pear.php.net/Net_UserAgent_Mobile-1.0.0

インストール確認

Shell
%pear list
Installed packages, channel pear.php.net:
=========================================
Package              Version State
Archive_Tar          1.3.3   stable
Console_Getopt       1.2.3   stable
Net_UserAgent_Mobile 1.0.0   stable
PEAR                 1.9.0   stable
Structures_Graph     1.0.3   stable
XML_Util             1.2.1   stable

php.iniのinclude_pathに追加

Shell
%vi /home/[your account]/www/php.ini
528 include_path=".:/home/[your account]/pear/php"

※include_pathに追記するのは、さくら管理画面の「PHP設定ファイルの編集」でもよい。

関連する記事:

Leave a Reply