Bcmath php как включить
Перейти к содержимому

Bcmath php как включить

  • автор:

Call to undefined function bcadd(). How to install bcmath

My site failed to load and I saw the above error “PHP Fatal error: Uncaught Error: Call to undefined function bcadd()” when I accessed my website in the web browser.

Bcmath PHP extension might not be enabled on your server and that might be reason why you got this error.

Do the below steps to install bcmath on your server.

Steps to Install bcmath module on Ubuntu or Debian Server

1. Log into your Ubuntu or Debian server as ‘root’ user or as any user with sudo privileges.

2. Run the command ‘dpkg --list | grep -i bcmath’ to check whether bcmath extension is already installed or not.

3. Run the command ‘apt-get install php-bcmath’ if bcmath extension is not installed

4. Run the command ‘php -m | grep bcmath’ to make sure the extension is enabled.

5. Create a phpinfo page under your website, if you are still getting the same error.

The php configuration file used by your website might be different if bcmath extension is still not showing enabled in phpinfo file.

Steps to install bcmath extension on Centos or Redhat Server

1. Log into your Linux server as ‘root’ user

2. Run the command ‘rpm -qa | grep -i bcmath’ to check whether bcmath extension is already installed.

3. Run the command ‘yum install php-bcmath’ to install bcmath extension on the server.

4. To verify whether the extension is enabled, you must run the command ‘php -m | grep bcmath’

5. Create a phpinfo file to verify bcmath extension is enabled.

Your site might be using a different php configuration file (php version other than default php version) if you are still getting the same error.

Steps to Install bcmath extension on Alpine Linux Server

1. Log into your Alpine Linux server as ‘root’ user

2. Run the command ‘apk install php7-bcmath’

3. Execute the command ‘php -m | grep bcmath’ to make sure the extension is enabled.

How to solve "The requested PHP extension bcmath is missing from your system" when installing a library via composer in Ubuntu 16.04

Carlos Delgado

Learn how to install the bcmath extension in your Ubuntu server for a specific PHP distribution.

How to solve "The requested PHP extension bcmath is missing from your system" when installing a library via composer in Ubuntu 16.04

A lot of packagist libraries that can be installed with composer require the famous bcmath extension. Thanks to the computers, you can easily run calculations on huge numbers with a high accuracy, however in some situations where the required amount of digits in the number exceeds the available memory of the computer, this high accuracy may be lower as expected nor may not work. That’s why this extension in PHP exists, to solve this problem. BCMath is set of PHP functions that allow to you to use Arbitrary-precision arithmetic. This package is basically going to be a wrapper for these functions so that they can be used in an object oriented way.

In some Ubuntu servers that aren’t being correctly configured, this extension may be missing, but don’t worry as you can easily install via the CLI running a simple command. Follow these steps to get the bcmath extension running on your PHP distribution and finally install the PHP libraries that rely on this extension as moontoast/math.

1. Verify which PHP version are you using

As first step, you need to know which PHP version are you using as you can’t simply install any version of the extension with any PHP version. To be sure of the version of PHP that you’re using, you can run this command from the CLI:

This will generate an output similar to:

PHP 7.0 Ubuntu php -v

Where you can easily identify the PHP version that you’re using. In our case, we are using PHP 7.0.

2. Install bcmath extension

Now that you know which PHP version are you using, you can simply install the respective version of bcmath using the following command:

After finishing the installation you will be able to use the bcmath extension and you won’t have the mentioned warning anymore.

service httpd restart

Pang's user avatar

When using the official PHP images of Docker, use docker-php-ext-install bcmath .

Was getting call to undefined function bcmod()

you should then see something similar to /etc/php.d/bcmath.ini listed under phpinfo.

If you have installed php 7.1 then this line work on your system.

check your php version in your system on ubuntu 16.04

and then result show there..

PHP 7.1.x+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Aug 19 2018 07:16:12) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.2.9-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

Sinto's user avatar

The following worked for me on Centos 7.4 with PHP 7.1 using remi repository.

First find out which PHP version I have:

Then search for bcmath extension in remi-php71 repository:

Now install the first matching extension:

Finally, restart php and nginx:

I found that the repo that had the package was not enabled. On OEL7,

and that worked.

I used the following command to find where the package was

Neo's user avatar

If you want to enable any extension then you have to install an extension first, extension maybe enabled but not installed, so taking the example of bcmath

yum search php-bcmath

Then ensure the php version in which u want to install this extension

You will get output like after yum search command>>

yum search php-bcmath** Loaded plugins: fastestmirror, universal-hooks Loading mirror speeds from cached hostfile

How to enable bcmath module in PHP 7.1

And it doesn’t seem to work. It also doesn’t appear in info.php page.

The php version I have is 7.1.12 something.

How do I enable it?

Nikk's user avatar

7 Answers 7

For reference purposes, on Ubuntu 16.04.5 LTS, with PHP 7.0, we use:

PHP will be using an additional repository, usually IUS or Remi, so it is likely that you need to install the php71-bcmath package.

Sorry for bumping an old post.

The problem was the command yum install php71-bcmath should be

yum install php7.1-bcmath

The correct command is:

also after installing it, you probably want to restart apache server if you are running one:

99problems's user avatar

If you’re using centos on linux, and need to 1st find what exact package applies; then the command you’re looking for is: yum search bcmath . This should return you a list of bcmath library applicable.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *