0

Im running nginx/php-fpm server in a docker container and I added an extension with

> docker-php-ext-install bcmath

bcmath functions are available on command line but not in script

i.e. this works:

> bash-4.4# php -r "echo bcdiv('105', '6.55957', 3);"
result=16.007

but this fails

// test.php
<?php
echo bcdiv('105', '6.55957', 3);  // 16.007
?>

when delivered as

http://test-server/test.php 

the result (in the browser) =

Fatal error: Uncaught Error: Call to undefined function bcdiv() in /var/www/html/web/test.php:3 Stack trace: #0 {main} thrown in /var/www/html/web/test.php on line 3

Why can the command line see the extension, but the script can't? Any help much appreciated. Thanks.

Laurence Fass
  • 1,614
  • 3
  • 21
  • 43
  • Probably have two ini files. One for CLI the other for php-fpm. My guess you need to uncomment the line in your php-fpm configuration to enable the module. Add a `phpinfo()` to your test.php and see what it shows you. – ficuscr Apr 25 '19 at 21:15

1 Answers1

0

Solution: Restarting nginx (in my case) was not sufficient. I had to restart php-fpm for changes to take effect. Result: works ok.

Laurence Fass
  • 1,614
  • 3
  • 21
  • 43