How do we install PHP5 under Linux? Here we will introduce the Linux PHP5 installation in detail. 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 PHP.
The following takes the installation of curl as an example to introduce the specific Linux PHP5 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
<ol class="dp-xml"> <li class="alt"><span><span>make </span></span></li> <li class=""><span>make install </span></li> </ol>
2. Compile and generate the extension into the ext directory in the php source program directory. The source code of each extension module is stored here. Choose your Required modules, such as curl module:
<ol class="dp-xml"><li class="alt"><span><span>cd curl </span></span></li></ol>
<ol class="dp-xml"> <li class="alt"><span><span>/usr/local/php5/bin/phpize </span></span></li> <li class=""> <span>./configure </span><span class="attribute"><font color="#ff0000">--with-curl</font></span><span>=/usr/local/curl </span><span class="attribute"><font color="#ff0000">--with-php-config</font></span><span>=/usr/local/php5/bin/php-config </span> </li> <li class="alt"><span> </span></li> <li class=""><span>make </span></li> <li class="alt"><span> </span></li> <li class=""><span>make install </span></li> </ol>
In this way, curl.so is copied to the PHP corresponding directory (such as: /usr/local/php5/lib /php/extensions/no-debug-non-zts-20090626/)
3. Modify the configuration in php.ini, set the extension directory:
<ol class="dp-xml"><li class="alt"><span><span class="attribute"><font color="#ff0000">extension_dir</font></span><span> = </span><span class="attribute-value"><font color="#0000ff">"/usr/local/php5/lib/php/extensions/no-debug-non-zts-20090626/"</font></span><span> </span></span></li></ol>
and add the extension module reference :
<ol class="dp-xml"><li class="alt"><span><span class="attribute"><font color="#ff0000">extension</font></span><span> = </span><span class="attribute-value"><font color="#0000ff">curl</font></span><span>.so </span></span></li></ol>
4. Check and restart Apache
<ol class="dp-xml"><li class="alt"><span><span>/usr/local/php/bin/php -v </span></span></li></ol>
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 follow Check the error message. The above are the steps for Linux PHP5 installation. I hope it will be helpful to everyone.