Home > Article > Backend Development > Install extensions when multiple versions of PHP coexist
There are two commonly used installation methods for installing PHP extensions
Compile and install
PECL
Today, for convenience, I directly used PECL to install. Later I found that there is There are two PHP versions, one is php-5.5.9 that comes with Ubuntu, and the other is php-5.5.38 of the integrated environment oneinstack.
As you can imagine, the extension is installed in php-5.5.9. In fact, I want to install it in php-5.5.38.
It can be seen that although PECL installation is convenient, it is not flexible enough
Then start using the compilation and installation method. The steps are generally as follows:
Download and expand to local (wget, git clone )
Unzip and enter the directory
phpize (if it is not installed, you must install php-dev)
./configure –with-php-config=/usr/local/php/bin/php-config ( Configure the specified PHP path)
make
sudo make install
Modify php.ini and add the extension to the configuration, such as extension=xxx.so (Similarly, you need to find the correct php.ini, such as/ usr/local/php/etc/php.ini)
Restart nginx and php-fpm
Use php -m | grep xxx, or php -i | grep xxx to check whether the installation is successful
Summary , when multiple PHP versions coexist, you can use compilation configuration to specify the PHP version, and the parameter used is –with-php-config.
Reprint: https://blog.csdn.net/u014101320/article/details/53401831
There are two common installation methods for installing PHP extensions
Compile and install
PECL
Today, for convenience, I directly used PECL to install it. Later I found that there are two PHP versions in my environment, one is php-5.5.9 that comes with Ubuntu, and the other is php-5.5 of the integrated environment oneinstack. 38.
As you can imagine, the extension is installed in php-5.5.9. In fact, I want to install it in php-5.5.38.
It can be seen that although PECL installation is convenient, it is not flexible enough
Then start using the compilation and installation method. The steps are generally as follows:
Download and expand to local (wget, git clone )
Unzip and enter the directory
phpize (if it is not installed, you must install php-dev)
./configure –with-php-config=/usr/local/php/bin/php-config ( Configure the specified PHP path)
make
sudo make install
Modify php.ini and add the extension to the configuration, such as extension=xxx.so (Similarly, you need to find the correct php.ini, such as/ usr/local/php/etc/php.ini)
Restart nginx and php-fpm
Use php -m | grep xxx, or php -i | grep xxx to check whether the installation is successful
Summary , when multiple PHP versions coexist, you can use compilation configuration to specify the PHP version, and the parameter used is –with-php-config.
The above is the detailed content of Install extensions when multiple versions of PHP coexist. For more information, please follow other related articles on the PHP Chinese website!