Search code examples
phplaravelubuntuservergmp

Missing BC Math or GMP extension in Laravel


I am running Laravel 5.7.14 on PHP 7.2-fpm on Ubuntu 16.04.

My code in the local environment was working fine, but once I uploaded it to the production server I got this error message: Missing BC Math or GMP extension.

I have installed both GMP + BC Math. When I run the command php -i | grep -i bcmath I get this:

/etc/php/7.2/cli/conf.d/20-bcmath.ini,
bcmath
BCMath support => enabled
bcmath.scale => 0 => 0

When I run php -m I get this:

[PHP Modules]
bcmath
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
readline
Reflection
session
shmop
SimpleXML
sockets
sodium
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlrpc
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

I have restarted the server multiple times and cleared Laravel's cache but nothing's changing, I keep getting this error message.

What am I missing here? If you need more info do not hesitate to ask.


Solution

  • Managing multiple PHP versions is sometimes very messy.

    If you are on a Linux-like system and try to upgrade PHP versions you sometimes end up with 2 versions on the same system. Not infrequently (especially when you manually have configured the previous version) the newly installed version does not get enabled to use with the webserver. Personally I've also experienced upgrading PHP and getting the apache to use the new version but as a module instead of FPM so you should also be wary of that if you are using apache since again FPM and the PHP module for apache might have different configurations as well.