Preloader
Ubuntu
  • Estimated reading time: 1 Minute

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

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:

php -v

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:

# As we have php 7.0
sudo apt install php7.0-bcmath

# According to the version of PHP that you use
# the package name changes as:
# php7.1-bcmath

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

Happy coding !

Share:
Carlos Delgado

Carlos Delgado

Senior Software Engineer at Software Medico. Interested in programming since he was 14 years old, Carlos is a self-taught programmer and founder and author of most of the articles at Our Code World.

Related articles
How to install the latest version of Git in Ubuntu 20.04
26 Aug, 2022
  • Estimated reading time: 1 Minute
How to install aapanel in Ubuntu 20.04
14 Aug, 2022
  • Estimated reading time: 1 Minute
How to install Prometheus Node Exporter on Ubuntu 20.04
27 Mar, 2022
  • Estimated reading time: 4 Minutes
How to extract the content of a tar.gz file in Ubuntu
16 Nov, 2021
  • Estimated reading time: 1 Minute
How to install Anaconda in Ubuntu 20.04
6 Nov, 2021
  • Estimated reading time: 3 Minutes
How to install Elasticsearch 7 in Ubuntu 20.04
29 Apr, 2021
  • Estimated reading time: 5 Minutes
Weekly trending
Apple Gift Card Rate Today in Nigeria (USD, CAD, GBP & More)
16 Jun, 2026
  • Estimated reading time: 4 Minutes
How Digital Airport Advertising Is Transforming the Industry
16 Jun, 2026
  • Estimated reading time: 4 Minutes
How Motorsports Sponsorship Agencies Measure Sponsorship ROI
16 Jun, 2026
  • Estimated reading time: 3 Minutes
Our Sponsors

Our blog is proudly supported by industry-leading sponsors.