Home > Article > Backend Development > Independently add PHP extension module mbstring_PHP tutorial under Linux
Environment php5.2.13, does not support mbstring extension
If the source code package of php is in /usr/local/src/php-5.2.13
The php installation directory is /usr/local/php
# cd /usr/local/src/php-5.2.13/ext/mbstring/
# rpm -qa|egrep "autoconf|gcc" This is to check whether these components are installed. If not, please perform the following sentence, otherwise an error will be reported
# yum -y install autoconf gcc gcc-c++
# phpize
# ./configure --with-php-config=/usr/local/bin/php-config
# make
# make install
After execution, add extension=mbstring.so in php.ini
Restart the web server and take a look at phpinfo. mbstring should be supported!
1. Install crul
wget http://curl.haxx.se/download/curl-7.19.6.tar.gz
tar -zxvf curl-7.19.6.tar.gz
cd curl-7.19.6
./configure --prefix=/usr/local/curl
make
make install
2. Compile and generate extensions
Enter the ext directory in the PHP source program directory. The source code of each extension module is stored here. Select the module you need, such as the curl module:
cd curl
Execute phpize to generate a compiled file. When phpize is run in the bin directory of the PHP installation directory
/usr/local/php5/bin/phpize
, an error may be reported: Cannot find autoconf. Please check your autoconf installation and the $ PHP_AUTOCONF
environment variable is set correctly and then rerun this script., need to install autoconf:
yum install autoconf (RedHat or CentOS), apt-get install autoconf (Ubuntu Linux)
Generate the configuration file and compile the generated module:
/usr/local/php5/bin/phpize
./configure --with-curl=/usr/local/curl --with-php-config =/usr/local/php5/bin/php-config
make
make install
The generated file is in (such as: /usr/local/php5/extensions/no-debug-non-zts-20090626 /)
In this way, curl.so is copied to the corresponding PHP directory (such as: /usr/local/php5/extensions/)
3. Modify the configuration
In php.ini, set the extension directory:
extension_dir = "/usr/local/php5/extensions/"
And add the extension module reference:
extension = curl.so
4. Check and restart Apache
/usr/local/php5/bin/php -v
When executing this command, php will check whether the configuration file is correct. If there is a configuration error, an error will be reported here. You can troubleshoot based on the error message