当前位置: 首页>>技术教程>>正文


如何在Ubuntu上为PHP7安装GMP

,

问题描述

尝试在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

第四种方案

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

第六种方案

更新:apt-get多年来发展成恰如其分。在现代系统上,这将检测php版本等。

sudo apt install php-gmp

第七种方案

谢谢,对我有帮助。我使用PHP 7.2。因此,我运行:

  1. sudo apt-get install php7.2-gmp

  2. extension=php_gmp.so

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/9482.html,未经允许,请勿转载。