在基於 Debian 的 Linux 發行版(Ubuntu、Mint、Kali 等)上安裝 PECL
使用 aptitude 命令
sudo apt-get install php-pear
希望對大家有幫助
PECL 讓建立共享 PHP 擴充功能變得容易。使用 » pecl 命令,執行以下操作
$ pecl install extname
這將下載 extname 的原始碼,進行編譯,並將 extname.so 安裝到 extension_dir 中。然後,可以透過 php.ini 載入 extname.so。
預設情況下,pecl 命令不會安裝標記為 alpha
或 beta
狀態的套件。如果沒有可用的 stable
套件,可以使用以下命令安裝 beta
套件
$ pecl install extname-beta
也可以使用以下變體安裝特定版本
$ pecl install extname-0.1
注意:
在 php.ini 啟用擴充功能後,需要重新啟動網路服務才能套用變更。
在基於 Debian 的 Linux 發行版(Ubuntu、Mint、Kali 等)上安裝 PECL
使用 aptitude 命令
sudo apt-get install php-pear
希望對大家有幫助
在 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
要在 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
要在 Fedora 中使用 pecl、pear 或 phpize 命令,請安裝 php-devel 套件
$ yum install php-devel