Home  >  Article  >  Backend Development  >  Compile PHP to generate extensions and modify configurations under Linux

Compile PHP to generate extensions and modify configurations under Linux

PHP中文网
PHP中文网Original
2017-03-24 09:45:061101browse

I would like to recommend a very good Linux PHP system to everyone, which is of great learning value. Here I will mainly explain the application of the Linux PHP system, including introducing Linux PHP knowledge and other aspects. After the server has been running for a period of time, you may suddenly need to add an extension, such as curl, pdo, xmlrpc, etc. This requires adding the extension independently without recompiling Linux PHP. The following takes the installation of curl and tidy as an example to introduce the specific installation steps.

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. Linux PHP compile and generate extensions

Enter the Linux PHP source program directory In the ext directory, the source code of each extension module is stored here. Select the module you need, such as the curl module: cd curl executes phpize to generate the compiled file. phpize is in the bin directory of the PHP installation directory /usr/local/php5/ When bin/phpize is run, 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.", you need to install autoconf: yum install autoconf (RedHat or CentOS), apt-get install autoconf (Ubuntu Linux)

Generate the configuration file, and compile the Linux PHP module to generate the module:

/usr/local/php5/bin/phpize  
./configure --with-curl=/usr/local/curl --with-php-config=/usr/local/php5/bin/php-config  
make  
make install

In this way, curl.so is copied to the corresponding PHP directory (such as: /usr/local/php5/lib/php/extensions/no-debug-non-zts-20090626/)

3.Linux PHP modification configuration

in Linux In PHP.ini, set the extension directory: extension_dir = "/usr/local/php5/lib/php/extensions/no-debug-non-zts-20090626/" and add the extension module reference: extension = curl.so

4. Check and restart Apache

/usr/local/php/bin/php -v When executing this command, Linux PHP will check whether the configuration file is correct. If there is If there is a configuration error, an error will be reported here. You can troubleshoot based on the error message. The same steps are followed to install the tidy extension.

However, the installation package of libtidy is more verified and the installation method is the same:
<.>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn