php 如何在 Ubuntu 上为 PHP7 安装 GMP
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40010197/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to install GMP for PHP7 on Ubuntu
提问by Sam Malayek
I was getting the following error when trying to run composer update
on a SimpleSAML project.
尝试composer update
在 SimpleSAML 项目上运行时出现以下错误。
- openid/php-openid dev-master requires ext-gmp * -> the requested PHP extension gmp is missing from your system.
Running sudo apt-get install php5-gmp
did not work and neither did sudo apt-get install php7-gmp
跑步sudo apt-get install php5-gmp
没有用,也没有sudo apt-get install php7-gmp
回答by Sam Malayek
To install GMP for PHP7.0 on Ubuntu, run:
sudo apt-get install php7.0-gmp
要在 Ubuntu 上为 PHP7.0 安装 GMP,请运行:
sudo apt-get install php7.0-gmp
Make sure your php.ini
contains the following:
extension=php_gmp.so
确保您php.ini
包含以下内容:
extension=php_gmp.so
To find out where your php.ini
is located, run:
php --ini
要找出您php.ini
所在的位置,请运行:
php --ini
回答by Bob Roan
For PHP 7.2:
对于 PHP 7.2:
sudo apt-get install php7.2-gmp
回答by Ales Rebec
The new way in PHP 7 to install extensions is to just write "php-EXTENSION" In this case it's as simple as:
PHP 7 中安装扩展的新方法是只写“php-EXTENSION”在这种情况下它很简单:
sudo apt-get install php-gmp
回答by anon
apt-get install php7.1-gmp
That's it.
就是这样。
回答by Wyatt
Thank you it helps me. I use PHP 7.2. Therefore, I run:
谢谢它对我有帮助。我使用 PHP 7.2。因此,我运行:
sudo apt-get install php7.2-gmp
extension=php_gmp.so
sudo apt-get install php7.2-gmp
extension=php_gmp.so
回答by Tarek Adam
UPDATE: apt-get has evolved over the years into just apt. On modern systems this will detect the php version, etc.
更新: apt-get 多年来已经演变成 apt。在现代系统上,这将检测 php 版本等。
sudo apt install php-gmp
sudo apt install php-gmp
回答by Tony Okoth
If you are running php 7.2 and above, then
如果您运行的是 php 7.2 及更高版本,那么
sudo apt-get install php7.2-gmp
sudo apt-get install php7.2-gmp
or you can as well install bcmath
extension using
或者你也可以bcmath
使用安装扩展
sudo apt-get install php7.2-bcmath
sudo apt-get install php7.2-bcmath
I recommend you install both of them, after complete install restart apache
我建议你安装它们,完成安装后重启apache
sudo service apache2 reload
sudo service apache2 reload
sudo service apache2 restart
sudo service apache2 restart
回答by king neo
for centos
对于centos
sudo yum install php-gmp
for ubuntu
对于 ubuntu
sudo apt install php-gmp
also enable php extension in ini file
还要在ini文件中启用php扩展
extension=php_gmp.so
回答by Ganesh K
It's better to search using package
or dependency manager
installed in machine.
For yum
, you can search using yum search gmp
and then install.
最好搜索使用package
或dependency manager
安装在机器上。对于yum
,您可以搜索使用yum search gmp
然后安装。
yum search gmp
This will yield these search results
这将产生这些搜索结果
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
Now install extension with:
yum install php-gmp.x86_64
现在安装扩展:
yum install php-gmp.x86_64
回答by Nelson Mfinda
For PHP 7.4:
对于 PHP 7.4:
sudo apt-get install php7.4-gmp
SO:Ubuntu 20.04
所以:Ubuntu 20.04