What should I do if some PHP extensions are not installed during compilation? -Php Tutorial

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.