Services/Amazon.phpとCache.phpに関するメモ(未解決)→追記:動作的には解決しました

PHPPEAR

Services/Amazon.phpとCache.phpに関するメモ(未解決)→追記:動作的には解決しました

 状態:不明  閲覧数:3,531  投稿日:2010-10-15  更新日:2010-10-15
Services/Amazon.phpで、Cache.phpを使いたい。
未解決。
放っておくと何が分からなかったのかすら分からなくなるので、分からない現状をメモしとく。

<分からないこと>
・Cache.phpとCache/Lite.phpの違い
・Services/Amazon.phpで、Cache.phpの使い方
・Services/Amazon.phpで、Cache/Lite.phpは使えるのか?
・ブラウザ上のpear-managerとコマンドは連動してないのか?
・include pathを設定すると、エラーになる理由
・コマンドpear listの意味。レンサバ側とユーザー領域と、2箇所見に行くということはできないのか?

<試したこと>
▽どこでも打てる。多分このリスト内容は、レンサバ側を見に行っていると思われる。
:~> pear list

Installed packages, channel pear.php.net:
=========================================
Package Version State
Archive_Tar 1.3.2 stable
Auth 1.5.4 stable
Auth_RADIUS 1.0.5 stable
Auth_SASL 1.0.2 stable
Cache_Lite 1.7.2 stable
Console_Getopt 1.2.3 stable
DB 1.7.12 stable
DB_DataObject 1.8.5 stable
DB_NestedSet 1.2.4 stable
DB_Pager 0.7 stable
DB_QueryTool 1.1.0 stable
DB_Table 1.5.0 stable
DB_ldap 1.1.1 stable
Date 1.4.7 stable
File_Archive 1.5.3 stable
File_Passwd 1.1.6 stable
HTML_AJAX 0.5.2 beta
HTML_Common 1.2.4 stable
HTML_QuickForm 3.2.9 stable
HTML_QuickForm_Controller 1.0.8 stable
HTML_Template_IT 1.2.1 stable
HTML_TreeMenu 1.2.0 stable
HTTP_Client 1.1.1 stable
HTTP_Request 1.4.1 stable
HTTP_Upload 0.9.1 stable
Image_Text 0.5.2beta2 beta
Log 1.9.11 stable
MDB 1.3.0 stable
MDB2 2.4.1 stable
MDB2_Driver_mysql 1.4.1 stable
MDB2_Driver_mysqli 1.4.1 stable
MDB2_Driver_pgsql 1.4.1 stable
MDB2_Driver_sqlite 1.4.1 stable
MIME_Type 1.0.0 stable
Mail 1.1.14 stable
Mail_Mime 1.5.2 stable
Mail_mimeDecode 1.5.0 stable
Net_POP3 1.3.6 stable
Net_SMTP 1.2.10 stable
Net_Socket 1.0.8 stable
Net_URL 1.0.15 stable
Net_UserAgent_Detect 2.3.0 stable
PEAR 1.6.1 stable
PEAR_Info 1.6.1 stable
Pager 2.4.3 stable
SQLite 1.0.3 stable
Services_Hatena 0.1.1 alpha
Services_OpenSearch 0.1.0 beta
Structures_Graph 1.0.2 stable
System_Command 1.0.6 stable
Text_CAPTCHA 0.1.6 alpha
Text_Figlet 1.0.0 stable
Text_Highlighter 0.6.9 beta
Text_Password 1.1.0 stable
Validate 0.6.4 beta
XML_Parser 1.2.8 stable
XML_RPC 1.5.1 stable
XML_RSS 0.9.9 beta
XML_Serializer 0.18.0 beta
XML_Tree 1.1 stable
XML_Util 1.1.4 stable
radius 1.2.4 stable


▽Cacheパッケージがないので、インストールしようとしたら、「あなたには書き込み権限がないので、インストールできません」、みたいなことを言われた。ここでようやく、レンサバ側を見に行っているらしいことに気付く。
:~> pear install Cache
Cannot install, php_dir for channel "pear.php.net" is not writeable by the current user


▽現在の設定を確認してみる
:~> pear config-show
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 pear.php.net
Default Channel Mirror preferred_mirror pear.php.net
Remote Configuration File remote_config <not set>
PEAR executables directory bin_dir /usr/local/bin
PEAR documentation directory doc_dir /usr/local/lib/php/doc
PHP extension directory ext_dir /usr/local/lib/php/extensions/no-debug-non-zts-20060613
PEAR directory php_dir /usr/local/lib/php
PEAR Installer cache directory cache_dir /tmp/pear/cache
PEAR data directory data_dir /usr/local/lib/php/data
PEAR Installer download download_dir /tmp/pear/cache
directory
PHP CLI/CGI binary php_bin /usr/local/bin/php
php.ini location php_ini <not set>
PEAR Installer temp directory temp_dir /tmp/pear/temp
PEAR test directory test_dir /usr/local/lib/php/test
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/local/bin/gpg
Signature Key Directory sig_keydir /usr/local/etc/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 /virtual/ユーザー名/.pearrc
System Configuration File Filename /usr/local/etc/pear.conf


▽ユーザー領域には、Cacheをインストールしたはずなので、そっちを見に行くよう、コマンドで設定を変更してみる
:~> pear config-set php_dir /virtual/ユーザー名/lib/PEAR/PEAR
config-set succeeded


▽設定が変更されたか確認してみる。php_dirは、ユーザー領域を見に行くよう変更されてた。
:~> pear config-show
Configuration (channel pear.php.net):
=====================================
PEAR directory php_dir /virtual/ユーザー名/lib/PEAR/PEAR


▽Cacheパッケージインストールしようとしてみる。既にインストールされている、とかで、インストール不可だった。
:~> pear install Cache
pear/Cache is already installed and is newer than detected release version 1.5.5
Cannot initialize 'Cache', invalid or missing package file
Package "Cache" is not valid
install failed


▽インストールされているpearのリストを表示。Cacheが無事表示された。
:~> pear list
Installed packages, channel pear.php.net:
=========================================
Package Version State
Archive_Tar 1.3.7 stable
Cache 1.5.5 stable
Cache_Lite 1.7.8 stable
Console_Getopt 1.2.3 stable
HTML_Template_IT 1.3.0 stable
HTTP_Request 1.4.4 stable
Net_Socket 1.0.9 stable
Net_URL 1.0.15 stable
PEAR 1.9.1 stable
PEAR_Frontend_Web 0.7.4 beta
Services_Amazon 0.8.0 beta
Structures_Graph 1.0.3 stable
XML_Parser 1.3.2 stable
XML_Serializer 0.20.0 beta
XML_Util 1.2.1 stable


▽これで無事解決かと思いきや、そうではなかった。
理由は不明。とりあえず、設定を一旦、元に戻しとくことにする。
:~> pear config-set php_dir /usr/local/lib/php
config-set succeeded


▽設定が戻っていることを確認
:~> pear list
Installed packages, channel pear.php.net:
=========================================
Package Version State
Archive_Tar 1.3.2 stable
Auth 1.5.4 stable
Auth_RADIUS 1.0.5 stable
Auth_SASL 1.0.2 stable
Cache_Lite 1.7.2 stable
Console_Getopt 1.2.3 stable
DB 1.7.12 stable
DB_DataObject 1.8.5 stable
DB_NestedSet 1.2.4 stable
DB_Pager 0.7 stable
DB_QueryTool 1.1.0 stable
DB_Table 1.5.0 stable
DB_ldap 1.1.1 stable
Date 1.4.7 stable
File_Archive 1.5.3 stable
File_Passwd 1.1.6 stable
HTML_AJAX 0.5.2 beta
HTML_Common 1.2.4 stable
HTML_QuickForm 3.2.9 stable
HTML_QuickForm_Controller 1.0.8 stable
HTML_Template_IT 1.2.1 stable
HTML_TreeMenu 1.2.0 stable
HTTP_Client 1.1.1 stable
HTTP_Request 1.4.1 stable
HTTP_Upload 0.9.1 stable
Image_Text 0.5.2beta2 beta
Log 1.9.11 stable
MDB 1.3.0 stable
MDB2 2.4.1 stable
MDB2_Driver_mysql 1.4.1 stable
MDB2_Driver_mysqli 1.4.1 stable
MDB2_Driver_pgsql 1.4.1 stable
MDB2_Driver_sqlite 1.4.1 stable
MIME_Type 1.0.0 stable
Mail 1.1.14 stable
Mail_Mime 1.5.2 stable
Mail_mimeDecode 1.5.0 stable
Net_POP3 1.3.6 stable
Net_SMTP 1.2.10 stable
Net_Socket 1.0.8 stable
Net_URL 1.0.15 stable
Net_UserAgent_Detect 2.3.0 stable
PEAR 1.6.1 stable
PEAR_Info 1.6.1 stable
Pager 2.4.3 stable
SQLite 1.0.3 stable
Services_Hatena 0.1.1 alpha
Services_OpenSearch 0.1.0 beta
Structures_Graph 1.0.2 stable
System_Command 1.0.6 stable
Text_CAPTCHA 0.1.6 alpha
Text_Figlet 1.0.0 stable
Text_Highlighter 0.6.9 beta
Text_Password 1.1.0 stable
Validate 0.6.4 beta
XML_Parser 1.2.8 stable
XML_RPC 1.5.1 stable
XML_RSS 0.9.9 beta
XML_Serializer 0.18.0 beta
XML_Tree 1.1 stable
XML_Util 1.1.4 stable
radius 1.2.4 stable


▽もう止めようかと思ったが、何だかんだでまだやってるので、メモ。
 pearを二箇所から呼ぶ方法だが、
 /直下の.pearrcファイルを直接変更すればいいのかと思って、やってみたが、駄目だった。「:」(コロン)がエラーになってるような気もするので、書き方の問題かもしれないが…。


▽そうこうしている内に、include_pathについては、いつの間にか通るようになってた。なんでだ?
 require_once('../../lib/set_include_path.php');
 require_once("Services/Amazon.php");
 require_once("Cache.php");

▼set_include_path.php
$path = '/virtual/ユーザー名/public_html/ドメイン名/originalSample/include:/virtual/ユーザー名/lib/PEAR/PEAR';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);

■今、もう一度試したらキャッシュファイルも無事に出来ていた! ラッキー。
 駄目だった理由。詳細は不明だが、どうもincludeパスの設定がおかしかったようだ。includeパスの設定のどこがおかしかったのかは不明だが、少なくとも、
require_once '/virtual/ユーザー名/lib/PEAR/PEAR/Services/Amazon.php';
require_once '/virtual/ユーザー名/lib/PEAR/PEAR/Cache.php';
のやり方では、駄目らしい。
というより、もしかしたら、元々設定されているinclude_pathに、ユーザー領域のinclude_pathが適切に追加されていなかったことが駄目だった原因のような気もする。

※/cache/の下にdefaultディレクトリを予め作成して、適切なパーミッションを設定しておく、みたいな記述も見かけたが、CGIモードで動かす限りは特に不要みたい。/cache/の下に何もなくても、自動的にdefaultディレクトリは作成された。


3日で出来ないPHPアプリケーション……試行錯誤メモ4