What should I do if some PHP extensions are not installed during compilation? When we configure the Web environment, sometimes the compiled environment meets the current requirements only.
However, with the development of business or architecture upgrade in the future, some new PHP extensions are required. at this time, we need to dynamically compile PHP extensions.
Today, I reconfigure a VM and run the new framework to report that fileinfo does not exist. an error of the Mine type is returned. I found that fileinfo was disabled during PHP upgrade, so now I need to dynamically compile the fileinfo extension.
The method is actually very simple!
1. First, check whether the required extensions are available. what is the PHP version?
Taking fileinfo as an example
/usr/bin/php -i|grep fileinfo
If fileinfo support => enabled is displayed, the fileinfo extension is available. Otherwise, the extension is unavailable.
View PHP version:
/usr/bin/php --version
The result may be as follows:
PHP 5.6.19 (cli) (built: Mar 3 2016 07:57:20)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
With Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
With Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans
2. find the PHP source code.
If not, download the version number of the current environment. The local source code already exists. switch to the source code directory.
cd /root/soft/php-5.6.19/ext
Ext is the extension directory under PHP, which contains extensions of PHP.
3. how to dynamically compile the extension, taking fileinfo extension as an example
Cd fileinfo/usr/local/php/bin/phpize ---- add the extension command to PHP dynamically under the php bin directory. /configure-with-php-config =/usr/local/php/bin/php-configmake & make install
4. add the extension name in php. ini.
Vi/etc/php. iniextension = fileinfo. so -- add extension name
Other extensions are similar