Chillu
Chillu

Reputation: 123

Function : bcmod is not available

I'm getting the following error while installing one of a joomla component.

Function : bcmod is not available. Please ask your hosts how you can enable this function in your PHP installation.

Upvotes: 9

Views: 19960

Answers (4)

Doberon
Doberon

Reputation: 648

Is needed install the library at Debian 10, also to do remove expired key of the repository before to install the bcmath

apt-key list 2>/dev/null | grep expired -B 1
apt-key del 95BD4743
apt-key list | grep expired
wget -O /etc/apt/trusted.gpg.d/deb.sury.gpg https://packages.sury.org/php/apt.gpg
apt-get update
apt install php7.2-bcmath
systemctl restart apache2

Upvotes: 0

Prabhu
Prabhu

Reputation: 198

You can install the bcmath package using installer. I am using CentOS so my commands are relatively different. You can use according to your OS.

yum install php-bcmath

Once you install the package,

If you are using php-fpm then you need to restart php-fpm service using

systemctl restart php-fpm

You need to restart http server at last

systemctl restart nginx

Upvotes: 4

m50
m50

Reputation: 816

If you have a dedicated server, try the solution given here https://stackoverflow.com/a/25229386/8015825.

Before recompiling, check the php.ini file and search for "bcmath". You may find bcmath.scale=0. If so, change the 0 to a 2.

And then restart your http server

Upvotes: 1

Alexey
Alexey

Reputation: 3484

you need your PHP to be compiled with bcmath support (--enable-bcmath configure option). If you're on shared hosting it is unlikely they will enable it for you. So you can try a solution from PHP manual from this page: http://ru.php.net/manual/en/function.bcmod.php I haven't tried it , but you can test it:

/** 
 * my_bcmod - get modulus (substitute for bcmod) 
 * string my_bcmod ( string left_operand, int modulus ) 
 * left_operand can be really big, but be carefull with modulus :( 
 * by Andrius Baranauskas and Laurynas Butkus :) Vilnius, Lithuania 
 **/ 
function my_bcmod( $x, $y ) 
{ 
    // how many numbers to take at once? carefull not to exceed (int) 
    $take = 5;     
    $mod = ''; 

    do 
    { 
        $a = (int)$mod.substr( $x, 0, $take ); 
        $x = substr( $x, $take ); 
        $mod = $a % $y;    
    } 
    while ( strlen($x) ); 

    return (int)$mod; 
} 

// example 
echo my_bcmod( "7044060001970316212900", 150 ); 

Upvotes: 12

Related Questions