How can I enable the PHP BC Math extension for a site?

I’m using a plugin that requires BC Math but I’m not sure how to enable it. I found information on how to install extensions but they involve downloading a package and installing. This, I believe is already included in PHP, it just needs to be enabled. The only instructions I’ve found are about installing php with it enabled, not enabling it after php is installed.

I found:

bcmath.scale = 0

in the php.ini file and set it to 2, restarted the site, but it still doesn’t show up in the php.ini file.

Hi Laura,

Here’s how you can compile BC Math for PHP 7.0.3 and other versions of PHP in Local:


Based off of the guides above, here’s how you can compile BC Math.

Download the version of PHP you’re running

  1. Go to (change 7.0.3 with the appropriate version)
  2. Extract the .tar.gz into the site’s app folder. The extracted folder should be adjacent to the public folder.

Download dependencies

  1. Right-click on the site in Local’s sidebar
  2. Go to “Open Site SSH”
  3. Run apt-get update && apt-get install -y build-essential autoconf pkg-config

Compile the extension

  1. Enter cd /app/php*/ext/bcmath
  2. Enter /opt/php/7.0.3/bin/phpize
  3. Enter ./configure --with-php-config=/opt/php/7.0.3/bin/php-config
  4. Enter make && make install. You should see something like Installing shared extensions: /opt/php/7.0.3/lib/php/extensions/no-debug-non-zts-20151012/
  5. Run ls -la PATH_FROM_ABOVE to see what the new extension filename is. It’ll be

Configuring PHP to use the extension

To finish up, follow the steps after Configure PHP to use the extension in this thread: How do I compile additional PHP extensions? - Local Classic FAQs - Local Community

Pre-compiled BC Math extension for PHP 7.0.3

For your convenience, here’s a precompiled version for PHP 7.0.3 that I created using the steps above.

To use it, you can do the following: (67.9 KB)

  1. Download and extract the zip into the site’s app folder so it should look something like app/
  2. Right-click on the site in Local and go to “Open Site SSH”
  3. Run: mv /app/ /opt/php/7.0.3/lib/php/extensions/no-debug-non-zts-20151012/
  4. Run: echo -e '\n\nextension = /opt/php/7.0.3/lib/php/extensions/no-debug-non-zts-20151012/' >> /conf/php/7.0.3/php.ini
  5. Restart the site in Local
  6. Check the PHP info for BC Math by clicking on the i by the PHP version number in Local
1 Like

I couldn’t use your pre-compiled extension as I am running PHP 5.6.20 on this site, but I followed your instructions and it worked perfectly. Thank you!

1 Like

Today, when I was in my WordPress admin, I this warning reappeared: Your website’s server does not have BC Math enabled which is required for the FlexMLS® IDX plugin. Please contact your webmaster and have this extension enabled on your website hosting plan. as if I had never installed it. I tried re-installing, but despite following the instructions exactly as I did before, when I view the PHP info file, it is not there. Any thoughts as to why this might be happening?

Did you switch PHP versions by chance?

No, I didn’t change anything. I was and am still using PHP 5.6.20.

It also seems pretty slow. My plugin updates kept timing out though I did eventually get them updated. I only have this one installation running.

if you want enable any extension then you have to install an extension first, extension maybe enabled but not installed so, taking example of bcmath
1.yum search php-bcmath
2.then ensure php version in which u want to install this extension
3.u will get output like after yum search command>>
yum search php-bcmath
Loaded plugins: fastestmirror, universal-hooks
Loading mirror speeds from cached hostfile

  • EA4:
  • cpanel-addons-production-feed:
  • base:
  • epel:
  • extras:
  • nux-dextop:
  • updates:
    ============================================================== N/S matched: php-bcmath ===============================================================
    ea-php54-php-bcmath.x86_64 : A module for PHP applications for using the bcmath library
    ea-php55-php-bcmath.x86_64 : A module for PHP applications for using the bcmath library
    ea-php56-php-bcmath.x86_64 : A module for PHP applications for using the bcmath library
    ea-php70-php-bcmath.x86_64 : A module for PHP applications for using the bcmath library
    ea-php71-php-bcmath.x86_64 : A module for PHP applications for using the bcmath library
    ea-php72-php-bcmath.x86_64 : A module for PHP applications for using the bcmath library
  1. then use >yum install ea-php72-php-bcmath.x86_64
    5.this bcmath extension for php7.2