用 PEAR 编译共享 PECL 扩展库

PECL 使建立共享 PHP 扩展库更容易。用 » pecl 命令这样做:


$ pecl install extname

这将下载 extname 的源代码,编译之,并将 extname.so 安装到 extension_dir 中。然后 extname.so 就可以通过 php.ini 加载了。

默认情况下,pecl 命令不会安装标记为 alphabeta 状态的包。如果没有 stable 包可用,也可以用以下命令安装一个 beta 包:


$ pecl install extname-beta

也可以用此命令安装一个指定的版本:


$ pecl install extname-0.1

注意:

php.ini 中启用扩展之后,需要重新启动 web 服务以使更改生效。

添加备注

用户贡献的备注 7 notes

up
20
giulliano dot scatalon dot rossi at gmail dot com
4 years ago
To install the PECL on debian based linux distros (ubuntu, mint, kali, etc.)
Use the apitude command:

sudo apt-get install php-pear

I hope helped someone
up
7
ezekial aikle
1 year ago
Options to pass to configure (with -D or --configureoptions=) need to be specified this way in a Dockerfile RUN command:

RUN pecl install -D 'with-example-dir="/dir" enable-example-thing="yes"' package
or
RUN pecl install --configureoptions='with-example-dir="/dir" enable-example-thing="yes"' package

Otherwise, docker build might quote the command in a way that pecl doesn't parse correctly, and the build will fail with an error like this one:

PHP Fatal error: Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, null given in /usr/local/lib/php/PEAR/Builder.php:397
up
8
Bichis Paul
7 years ago
on Mageia Linux use urpmi

[afk@mageia5][~]$ sudo urpmi php-pear
up
9
ktcox at mail dot com
13 years ago
The Arch Linux package that contains PECL is 'php-pear'

# pacman -S php-pear
up
7
ericn at amazon dot com
10 years ago
To compile pecl extensions on Amazon Linux AMIs, follow the tutorial at http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/install-LAMP.html and then install these additional required packages with the following command:

[ec2-user ~]$ sudo yum install php-devel zlib-devel curl-devel gcc

You should then be able to compile pecl extensions; for example, enter the following command to compile the pecl_http extension:

[ec2-user ~]$ sudo pecl install pecl_http
up
7
zir dot echo at gmail dot com
16 years ago
Install pecl for gentoo:

emerge dev-php/PEAR-PEAR
up
3
pedro dot fonini at gmail dot com
16 years ago
to use the pecl, pear, or phpize commands in fedora, install the php-devel package:
$ yum install php-devel
To Top