2024 年日本 PHP 研討會

使用 pecl 命令編譯共享 PECL 擴充功能

PECL 讓建立共享 PHP 擴充功能變得容易。使用 » pecl 命令,執行以下操作

$ pecl install extname

這將下載 extname 的原始碼,進行編譯,並將 extname.so 安裝到 extension_dir 中。然後,可以透過 php.ini 載入 extname.so

預設情況下,pecl 命令不會安裝標記為 alphabeta 狀態的套件。如果沒有可用的 stable 套件,可以使用以下命令安裝 beta 套件

$ pecl install extname-beta

也可以使用以下變體安裝特定版本

$ pecl install extname-0.1

注意:

php.ini 啟用擴充功能後,需要重新啟動網路服務才能套用變更。

新增註記

使用者貢獻的註記 7 則註記

giulliano dot scatalon dot rossi at gmail dot com
4 年前
在基於 Debian 的 Linux 發行版(Ubuntu、Mint、Kali 等)上安裝 PECL
使用 aptitude 命令

sudo apt-get install php-pear

希望對大家有幫助
ezekial aikle
1 年前
在 Dockerfile 的 RUN 命令中,需要以這種方式指定要傳遞給 configure 的選項(使用 -D 或 --configureoptions=)

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

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

否則,docker build 可能會以 pecl 無法正確解析的方式引用命令,並且建置將會失敗並顯示如下錯誤:

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
Bichis Paul
7 年前
在 Mageia Linux 上使用 urpmi

[afk@mageia5][~]$ sudo urpmi php-pear
ktcox at mail dot com
13 年前
包含 PECL 的 Arch Linux 套件是 'php-pear'

# pacman -S php-pear
ericn at amazon dot com
11 年前
要在 Amazon Linux AMI 上編譯 pecl 擴充功能,請遵循 http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/install-LAMP.html 的教學,然後使用以下命令安裝這些額外的必要套件

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

然後您應該能夠編譯 pecl 擴充功能;例如,輸入以下命令來編譯 pecl_http 擴充功能

[ec2-user ~]$ sudo pecl install pecl_http
zir dot echo at gmail dot com
16 年前
為 Gentoo 安裝 pecl

emerge dev-php/PEAR-PEAR
pedro dot fonini at gmail dot com
16 年前
要在 Fedora 中使用 pecl、pear 或 phpize 命令,請安裝 php-devel 套件
$ yum install php-devel
To Top