Home >Backend Development >PHP Tutorial >Use phpize to dynamically add extensions to PHP under Linux_PHP tutorial
A common problem when using PHP is: I forgot to add an extension when compiling PHP. I want to add the extension later, but because I installed some things such as PEAR after installing PHP, I don’t want to delete the directory and reinstall it. Don’t tell me, PHP is really like this. function.
I didn’t see it in the manual.
If I want to add bcmath support, this is an extension that supports large integer calculations. Windows comes with it and is built-in. Linux "This type of function is only available when --enable-bcmath is configured when PHP is compiled" (the quotes are from the manual)
Fortunately, there is phpize,
The method is to have a php compressed package that is exactly the same as the existing php. I'm using php-5.2.6.tar.gz.
Expand and enter the ext/bcmath directory inside
Then execute /usr/local/php/bin/phpize, which is an executable text file. Make sure it is in the system
You will find that there are some more configure files in the current directory,
If no error is reported, then
Php code
./configure --with-php-config=/usr/local/php/bin/php-config
Note that you must first ensure that /usr/local/php/bin/php-config exists.
If your PHP installation path is not the default, you need to change it.
If no error is reported, make, then make install, and then it will tell you a directory
You copy bcmath.so in this directory to the directory pointed to by extension_dir in your php.ini,
Modify php.ini and add extension=bcmath.so at the end
Restart apache.