PHP 学習:PEARのインストール

公開:2026.04.18 11:37

PEAR

PEAR と書いて "ペア"(梨) と呼ぶ。 PEAR = PHP Extension and Application Repository
PHPのライブラリやパッケージを管理するシステムのこと。

いまさらながらPEARを使おうと思っていたが、もう昔のものらしい。
今の主流はComposerとのこと。

図書館で「プロになるためのPHPプログラミング入門」という本を借りたが、出版は2012年2月。
HTML_Template_Flexyというのを使っていて(これも現在は非推薦)、そしてこれを使うにはPEARが必要、ということで先に進むためPEARとHTML_Template_Flexyを入れることにした。

こういう技術本はなるべく最新のものを読まないと苦労する。

環境

◆ Windows 11 25H2 (26200.8037) + WSL + Docker
◆ WSL:
PS C:\Users\xxx> wsl --version
WSL バージョン: 2.3.24.0
カーネル バージョン: 5.15.153.1-2
WSLg バージョン: 1.0.65
MSRDC バージョン: 1.2.5620
Direct3D バージョン: 1.611.1-81528511
DXCore バージョン: 10.0.26100.1-240331-1435.ge-release
Windows バージョン: 10.0.26200.8037
◆ Ubuntu:
xxx@xxx:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 24.04.1 LTS
Release: 24.04
Codename: noble

PHP環境

過去記事:Docker 学習 #4:Docker Composeを学ぶ で作成したPHPコンテナを使用する。
以下コマンドでコンテナを起動。
docker compose up -d

コンテナのbashに接続する。
docker exec -it (CONTAINER ID) /bin/bash
※ (CONTAINER ID)は "docker ps" コマンドで確認。

PEAR環境を作る

Geminiに聞いてみた。

[方法1] パッケージマネージャを使ってインストールする。
apt update
apt install php-pear

実行結果: インストールできなかった
root@xxx:~/docker/php# docker exec -it 05fa4e42bbcd /bin/bash
root@05fa4e42bbcd:/var/www/html# apt update
Hit:1 http://deb.debian.org/debian trixie InRelease
Get:2 http://deb.debian.org/debian trixie-updates InRelease [47.3 kB]
Get:3 http://deb.debian.org/debian-security trixie-security InRelease [43.4 kB]
Get:4 http://deb.debian.org/debian trixie/main amd64 Packages [9671 kB]
Get:5 http://deb.debian.org/debian trixie-updates/main amd64 Packages [5412 B]
Get:6 http://deb.debian.org/debian-security trixie-security/main amd64 Packages [124 kB]
Fetched 9891 kB in 3s (3833 kB/s)
3 packages can be upgraded. Run 'apt list --upgradable' to see them.
root@05fa4e42bbcd:/var/www/html# apt install php-pear
Package php-pear is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

Error: Package 'php-pear' has no installation candidate
  
[方法2] go-pear.pharを使って直接インストールする。
wget http://pear.php.net/go-pear.phar

実行結果:
root@05fa4e42bbcd:/var/www/html# wget http://pear.php.net/go-pear.phar
bash: wget: command not found
  
wgetが無いらしいのでインストール:
root@05fa4e42bbcd:/var/www/html# apt install wget
Installing:
  wget

Summary:
  Upgrading: 0, Installing: 1, Removing: 0, Not Upgrading: 3
  Download size: 984 kB
  Space needed: 3875 kB / 1017 GB available

Get:1 http://deb.debian.org/debian trixie/main amd64 wget amd64 1.25.0-2 [984 kB]
Fetched 984 kB in 0s (3695 kB/s)
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 79,  line 1.)
debconf: falling back to frontend: Readline
Selecting previously unselected package wget.
(Reading database ... 15584 files and directories currently installed.)
Preparing to unpack .../wget_1.25.0-2_amd64.deb ...
Unpacking wget (1.25.0-2) ...
Setting up wget (1.25.0-2) ...
  
もう一度 go-pear.phar のダウンロードをやってみる。
今度はOK!
root@05fa4e42bbcd:/var/www/html# wget http://pear.php.net/go-pear.phar
--2026-04-18 07:17:30--  http://pear.php.net/go-pear.phar
Resolving pear.php.net (pear.php.net)... 109.203.101.62
Connecting to pear.php.net (pear.php.net)|109.203.101.62|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://pear.php.net/go-pear.phar [following]
--2026-04-18 07:17:31--  https://pear.php.net/go-pear.phar
Connecting to pear.php.net (pear.php.net)|109.203.101.62|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3637615 (3.5M)
Saving to: 'go-pear.phar'

go-pear.phar                  100%[=================================================>]   3.47M   318KB/s    in 14s

2026-04-18 07:17:47 (246 KB/s) - 'go-pear.phar' saved [3637615/3637615]
  
続いて インストール実行
php go-pear.phar

実行結果:なにやら色々聞いてきた。[Enter]押せばいいとのこと。
root@05fa4e42bbcd:/var/www/html# php go-pear.phar
PHP Warning:  Private methods cannot be final as they are never overridden by other classes in /var/www/html/go-pear.phar on line 339

Warning: Private methods cannot be final as they are never overridden by other classes in /var/www/html/go-pear.phar on line 339

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/local
 2. Temporary directory for processing            : /tmp/pear/install
 3. Temporary directory for downloads             : /tmp/pear/install
 4. Binaries directory                            : /usr/local/bin
 5. PHP code directory ($php_dir)                 : /usr/local/lib/php
 6. Documentation directory                       : /usr/local/docs
 7. Data directory                                : /usr/local/data
 8. User-modifiable configuration files directory : /usr/local/cfg
 9. Public Web Files directory                    : /usr/local/www
10. System manual pages directory                 : /usr/local/man
11. Tests directory                               : /usr/local/tests
12. Name of configuration file                    : /usr/local/etc/pear.conf

1-12, 'all' or Enter to continue:    
  
インストール完了:
Beginning install...
Configuration written to /usr/local/etc/pear.conf...
Initialized registry...
Preparing to install...
installing phar:///var/www/html/go-pear.phar/PEAR/go-pear-tarballs/Archive_Tar-1.6.0.tar...
installing phar:///var/www/html/go-pear.phar/PEAR/go-pear-tarballs/Console_Getopt-1.4.3.tar...
installing phar:///var/www/html/go-pear.phar/PEAR/go-pear-tarballs/PEAR-1.10.18.tar...
installing phar:///var/www/html/go-pear.phar/PEAR/go-pear-tarballs/Structures_Graph-1.2.0.tar...
installing phar:///var/www/html/go-pear.phar/PEAR/go-pear-tarballs/XML_Util-1.4.5.tar...
warning: pear/PEAR dependency package "pear/Archive_Tar" downloaded version 1.6.0 is not the recommended version 1.4.4
warning: pear/PEAR dependency package "pear/Structures_Graph" downloaded version 1.2.0 is not the recommended version 1.1.1
install ok: channel://pear.php.net/Archive_Tar-1.6.0
install ok: channel://pear.php.net/Console_Getopt-1.4.3
install ok: channel://pear.php.net/Structures_Graph-1.2.0
install ok: channel://pear.php.net/XML_Util-1.4.5
install ok: channel://pear.php.net/PEAR-1.10.18
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"

The 'pear' command is now at your service at /usr/local/bin/pear

** The 'pear' command is not currently in your PATH, so you need to
** use '/usr/local/bin/pear' until you have added
** '/usr/local/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!
  


PHP 学習

0 件のコメント:

コメントを投稿