Home > Backend Development > PHP Tutorial > Detailed introduction to Linux PHP5 installation steps_PHP tutorial

Detailed introduction to Linux PHP5 installation steps_PHP tutorial

WBOY
Release: 2016-07-15 13:28:34
Original
995 people have browsed it

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>
Copy after login

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>
Copy after login

Execute 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) generates the configuration file and compiles the generated module:
<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>
Copy after login

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>
Copy after login

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>
Copy after login

4. Check and restart Apache

<ol class="dp-xml"><li class="alt"><span><span>/usr/local/php/bin/php -v </span></span></li></ol>
Copy after login

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.


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/446447.htmlTechArticleHow 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, p...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template