簡體   English   中英

如何在 Ubuntu 上為 PHP7 安裝 GMP

[英]How to install GMP for PHP7 on Ubuntu

嘗試在 SimpleSAML 項目上運行composer update時出現以下錯誤。

- openid/php-openid dev-master requires ext-gmp * -> the requested PHP extension gmp is missing from your system.

運行sudo apt-get install php5-gmp不起作用, sudo apt-get install php7-gmp

要在 Ubuntu 上為 PHP7.0 安裝 GMP,請運行: sudo apt-get install php7.0-gmp

確保您的php.ini包含以下內容: extension=php_gmp.so

要找出php.ini所在的位置,請運行: php --ini

對於 PHP 7.2:

sudo apt-get install php7.2-gmp

PHP 7 中安裝擴展的新方法是只寫“php-EXTENSION”在這種情況下它很簡單:

sudo apt-get install php-gmp

對於 PHP 7.4:

sudo apt-get install php7.4-gmp

所以: Ubuntu 20.04

謝謝它對我有幫助。 我使用 PHP 7.2。 因此,我運行:

  1. sudo apt-get install php7.2-gmp
  2. extension=php_gmp.so
apt-get install php7.1-gmp

就是這樣。

如果您運行的是 php 7.2 及更高版本,那么

sudo apt-get install php7.2-gmp

或者您也可以使用安裝bcmath擴展

sudo apt-get install php7.2-bcmath

我建議你安裝它們,完成安裝后重啟apache

sudo service apache2 reload

sudo service apache2 restart

對於基於php:7.2-fpm等官方 php 鏡像php:7.2-fpm

只需將其添加到 Dockerfile

RUN apt install -y libgmp-dev && docker-php-ext-install gmp

對於centos

sudo yum install php-gmp

對於 ubuntu

sudo apt install php-gmp

還要在ini文件中啟用php擴展

extension=php_gmp.so

更新: apt-get 多年來已經演變成 apt。 在現代系統上,這將檢測 php 版本等。

sudo apt install php-gmp

最好使用安裝在機器上的packagedependency manager進行搜索。 對於yum ,您可以使用yum search gmp進行yum search gmp ,然后安裝。

yum search gmp

這將產生這些搜索結果

Loaded pluginss: extras_suggestions, langpacks, priorities, update-motd
170 packages excluded due to repository priority protections
========================================================= N/S matched: gmp ==========================================================
perl-Math-BigInt-GMP.x86_64 : Math::BigInt::GMP Perl module
python-gmpy2.x86_64 : Python 2 interface to GMP, MPFR, and MPC
gmp.x86_64 : A GNU arbitrary precision library
gmp.i686 : A GNU arbitrary precision library
gmp-devel.x86_64 : Development tools for the GNU MP arbitrary precision library
gmp-static.x86_64 : Development tools for the GNU MP arbitrary precision library
mingw32-gmp.noarch : Cross-compiled GNU arbitrary precision library
mingw64-gmp.noarch : Cross-compiled GNU arbitrary precision library
perl-Math-GMP.x86_64 : High speed arbitrary size integer math
php-gmp.x86_64 : A module for PHP applications for using the GNU MP library

現在安裝擴展: yum install php-gmp.x86_64

對於 PHP 7.3,試試這個。

sudo apt-get install php7.3 -gmp
extension=php_gmp.so

在 Ubuntu 中

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM