Slime: php5.6 source installation and PHP-FPM configuration

Source: Internet
Author: User
Tags sapi

This article starts in the Slime row world.

LNMP environment in the building, now only PHP has no source installed. This article will introduce you to this.

Note This article uses the CentOS 6.5 64bit.

Login to CentOS to download the php5.6 installation package. PHP package can go to the domestic souhu mirror site to download.

wget http://mirrors.sohu.com/php/php-5.6.2.tar.gz

650) this.width=650; "title=" clip_image001[4] "style=" border-left-0px; border-right-width:0px; Background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image001[4] "src=" http://img1.51cto.com/attachment/201410/29/526870_ 1414574857k7t1.png "width=" 549 "height="/>

Before installing, we need to install the packages that php5.6 compile on. As follows:

Yum-y install gcc gcc-c++ libxml2 libxml2-devel

650) this.width=650; "title=" clip_image002[4] "style=" border-left-0px; border-right-width:0px; Background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image002[4] "src=" http://img1.51cto.com/attachment/201410/29/526870_ 1414574857u0js.png "width=" 548 "height=" 151 "/>

650) this.width=650; "title=" clip_image003[4] "style=" border-left-0px; border-right-width:0px; Background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image003[4] "src=" http://img1.51cto.com/attachment/201410/29/526870_ 1414574858ptvd.png "width=" 344 "height=" 238 "/>

After installing the above package, we will now unpack the php5.6 source package just downloaded. Use the following command:

TAR-XF php-5.6.2.tar.gz

650) this.width=650; "title=" clip_image004[4] "style=" border-left-0px; border-right-width:0px; Background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image004[4] "src=" http://img1.51cto.com/attachment/201410/29/526870_ 1414574858fjiy.png "width=" 522 "height=" 283 "/>

Enter the php5.6 directory, and now start configuring php5.6, using the following command:

CD php-5.6.2

./configure--ENABLE-FPM--enable-mbstring--with-mysql=/usr/local/mysql

650) this.width=650; "title=" clip_image005[4] "style=" border-left-0px; border-right-width:0px; Background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image005[4] "src=" http://img1.51cto.com/attachment/201410/29/526870_ 1414574858qw9k.png "Width=" 702 "height="/>

If there is no error, after the configuration is complete. The system will appear with the following prompt message:

650) this.width=650; "title=" clip_image006[4] "style=" border-left-0px; border-right-width:0px; Background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image006[4] "src=" http://img1.51cto.com/attachment/201410/29/526870_ 141457485973uf.png "width=" 414 "height=" 347 "/>

Note that the role of--ENABLE-FPM in the above command is to open the fastcgi function of PHP is to turn on the PHP-FPM function,--with-mysql=/usr/local/mysql is to enable PHP support MySQL features,/usr/local/ MySQL is the installation path for the MySQL database.

--enable-mbstring means that the primary function of enabling the Mbstring Module Mbstring module is to detect and convert the encoding, providing a string function for the corresponding multibyte operation. At present PHP internal code only supports iso-8859-*, EUC-JP, UTF-8, the other encoding language is not able to display correctly in the PHP program, so we want to enable the Mbstring module.

At the same time we are just simple to open and expand a part of PHP features, other required features, please add it yourself.

Once the configuration is complete, we will now compile PHP, using the Make command, as follows:

Make

650) this.width=650; "title=" clip_image007[4] "style=" border-left-0px; border-right-width:0px; Background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image007[4] "src=" http://img1.51cto.com/attachment/201410/29/526870_ 1414574859mpso.png "width=" 571 "height=" 201 "/>

PHP compiled for a long time, depending on the performance of the machine needs to wait about 10-20 minutes. After compiling, the following:

650) this.width=650; "title=" clip_image008[4] "style=" border-left-0px; border-right-width:0px; Background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image008[4] "src=" http://img1.51cto.com/attachment/201410/29/526870_ 1414574859ectw.png "width=" 583 "height=" 274 "/>

After compiling, we will now start to install PHP, using the following command:

Make install

650) this.width=650; "title=" clip_image009[4] "style=" border-left-0px; border-right-width:0px; Background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image009[4] "src=" http://img1.51cto.com/attachment/201410/29/526870_ 14145748601bop.png "width=" "height=" 346 "/>

Once the installation is complete, we can see if the installation was successful with the PHP–V command. As follows:

Php–v

650) this.width=650; "title=" clip_image010[4] "style=" border-left-0px; border-right-width:0px; Background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image010[4] "src=" http://img1.51cto.com/attachment/201410/29/526870_ 1414574860dy5o.png "width=" 501 "height=" "/>

After this installation, you will find that there are no php.ini files in the/usr/local/lib directory. In this we will first copy the PHP installation files provided by the template, as follows:

CP Php.ini-production/usr/local/lib/php.ini

650) this.width=650; "title=" clip_image011[4] "style=" border-left-0px; border-right-width:0px; Background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image011[4] "src=" http://img1.51cto.com/attachment/201410/29/526870_ 1414574860y31g.png "width=" 579 "height=" 118 "/>

Note php.ini files are generally in the/usr/local/lib/and/etc directories. After the installation of PHP, there is no php.ini file, we re-introduce another article.

Do not assume that the installation of PHP is complete, LNMP environment in the Nginx is not supported by PHP, need to fastcgi to handle the request for PHP. and PHP needs to php-fpm this component to support it.

Prior to php5.3.3 version php-fpm is in the form of a patch package, and php5.3.3 after the PHP-FPM only need to install PHP-FPM to enable this feature. This is the front, we then configure PHP to use the command--enable-fpm.

After the PHP-FPM function is turned on, we also need to configure PHP-FPM. In fact, PHP-FPM configuration file in the installation of PHP, we have provided a template for the configuration file. This template is/usr/local/etc/php-fpm.conf.default, as follows:

More/usr/local/etc/php-fpm.conf.default

650) this.width=650; "title=" clip_image012[4] "style=" border-left-0px; border-right-width:0px; Background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image012[4] "src=" http://img1.51cto.com/attachment/201410/29/526870_ 1414574861wkeb.png "width=" 583 "height=" 280 "/>

Now we just need to copy the file and rename it to Php-fpm.conf, as follows:

Cp/usr/local/etc/php-fpm.conf.default/usr/local/etc/php-fpm.conf

650) this.width=650; "title=" clip_image013[4] "style=" border-left-0px; border-right-width:0px; Background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image013[4] "src=" http://img1.51cto.com/attachment/201410/29/526870_ 1414574861j086.png "width=" 696 "height=" "/>

In order for PHP-FPM to be started in the form of service. We need to copy the PHP installation directory under the/SAPI/FPM/INIT.D.PHP-FPM file. As follows:

CP./SAPI/FPM/INIT.D.PHP-FPM/ETC/INIT.D/PHP-FPM

650) this.width=650; "title=" clip_image014[4] "style=" border-left-0px; border-right-width:0px; Background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image014[4] "src=" http://img1.51cto.com/attachment/201410/29/526870_ 1414574861uvf7.png "width=" 550 "height="/>

Through, we can also clearly see that the php-fpm file does not currently have execute permissions. Give php-fpm Execute permissions, and start php-fpm as follows:

chmod a+x/etc/init.d/php-fpm

/ETC/INIT.D/PHP-FPM start

NETSTAT-TUNLP |grep 9000

650) this.width=650; "title=" clip_image015[4] "style=" border-left-0px; border-right-width:0px; Background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image015[4] "src=" http://img1.51cto.com/attachment/201410/29/526870_ 1414574862tpnw.png "width=" 735 "height=" 144 "/>

Through, we can obviously see that the PHP-FPM has started normally.

Note that the default listener for PHP-FPM is Port 9000.

Now configure Nginx so that it supports PHP, as follows:

Location ~ \.php$ {

root HTML;

Fastcgi_pass 127.0.0.1:9000;

Fastcgi_index index.php;

Fastcgi_param script_filename $document _root$fastcgi_script_name;

Include Fastcgi_params;

}

650) this.width=650; "title=" clip_image016[4] "style=" border-left-0px; border-right-width:0px; Background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image016[4] "src=" http://img1.51cto.com/attachment/201410/29/526870_ 1414574862yeby.png "width=" 571 "height=" 498 "/>

Then, in the Nginx Web site root directory, the new index.php file content is as follows:

vi/usr/local/nginx/html/index.php

<?php phpinfo ();?>

650) this.width=650; "title=" clip_image017[4] "style=" border-left-0px; border-right-width:0px; Background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image017[4] "src=" http://img1.51cto.com/attachment/201410/29/526870_ 1414574862rnzn.png "width=" 473 "height="/>

Now to start Nginx, as follows:

/usr/local/nginx/sbin/nginx

NETSTAT-TUNLP |grep 80

650) this.width=650; "title=" clip_image018[4] "style=" border-left-0px; border-right-width:0px; Background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image018[4] "src=" http://img1.51cto.com/attachment/201410/29/526870_ 1414574863dg4w.png "width=" 713 "height=" "/>"

After the Nginx boot is complete, now visit the website as follows:

650) this.width=650; "title=" clip_image019[4] "style=" border-left-0px; border-right-width:0px; Background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; margin:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image019[4] "src=" http://img1.51cto.com/attachment/201410/29/526870_ 1414574863grvh.png "width=" 1249 "height=" 405 "/>

650) this.width=650; "title=" clip_image020[4] "style=" border-left-0px; border-right-width:0px; Background-image:none; border-bottom-width:0px; padding-top:0px; padding-left:0px; padding-right:0px; border-top-width:0px "border=" 0 "alt=" clip_image020[4] "src=" http://img1.51cto.com/attachment/201410/29/526870_ 1414574864spgn.png "width=" 1017 "height=" 283 "/>

Through, we can obviously see. PHP has been successfully installed and has successfully supported the MySQL database. At the same time, the integration with Nginx is complete.

So far. The installation of our php5.6 ends here.

Slime: php5.6 source installation and PHP-FPM configuration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.