Rotten mud: php5.6 source code installation and php

Source: Internet
Author: User
Tags php software sapi
This article was sponsored by Xiuyi linfeng and first launched in the dark world. Currently, only php has no source code installed. This article will introduce this article. Note the centos6.564bit used in this article. Log on to centos to download the php5.6 installation package. Php software packages can be downloaded from the souhu image site in China. Wgeth

This article was sponsored by Xiuyi linfeng and first launched in the dark world. Currently, only php has no source code installed. This article will introduce this article. Note that centos 6.5 64bit is used in this article. Log on to centos to download the php5.6 installation package. Php software packages can be downloaded from the souhu image site in China. Wget h

This article was sponsored by Xiuyi linfeng and first launched in the dark world.

Currently, only php has no source code installed. This article will introduce this article.

Note that centos 6.5 64bit is used in this article.

Log on to centos to download the php5.6 installation package. Php software packages can be downloaded from the souhu image site in China.

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

Before installation, We need to install the software package on which php5.6 is compiled. As follows:

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

After the above software package is installed, We will decompress the php5.6 source code package we just downloaded. Run the following command:

Tar-xf php-5.6.2.tar.gz

Go to the extract directory of php5.6 and configure php5.6. Run the following command:

Cd php-5.6.2

./Configure -- enable-fpm -- enable-mbstring -- with-mysql =/usr/local/mysql

If there is no error, after the configuration is complete. The following message is displayed:

Note that in the preceding command -- enable-fpm is used to enable the php-fpm function by enabling the fastcgi function of php, -- with-mysql =/usr/local/mysql is to enable php to support mysql, and/usr/local/mysql is the installation path of mysql database.

-- Enable-mbstring indicates that the main function of enabling the mbstring module of the mbstring module is to detect and convert the encoding and provide the corresponding string functions for multi-byte operations. Currently php internal encoding only supports ISO-8859-*, EUC-JP, UTF-8, Other encoding languages can not be correctly displayed on the php program, so we want to enable the mbstring module.

At the same time, we simply enable and expand some of the php functions. For other required functions, please add them on your own.

After the configuration is complete, compile php now and use the make command as follows:

Make

Php compilation takes about 10-20 minutes depending on the machine performance. After compilation:

After compilation, we will start to install php and use the following command:

Make install

After the installation is complete, run the php-v command to check whether the installation is successful. As follows:

Php-v

After installation, you will find that the php. ini file is not in the/usr/local/lib directory. Here we will first copy the template provided by the php installation file, as shown below:

Cp php. ini-production/usr/local/lib/php. ini

Note that the php. ini file is usually in the/usr/local/lib/and/etc directories. If the php. ini file does not exist after the installation is completed, we will introduce it in another article.

Do not assume that the php installation is complete. nginx in the lnmp environment does not support php. fastcgi must be used to process php requests. Php requires the php-fpm component.

Php-fpm versions earlier than php5.3.3 exist in the form of a patch package. php-fpm Versions later than php5.3.3 only need to enable this function when installing php-fpm. This is the frontend. We can configure the command "enable-fpm" used by php.

After the php-fpm function is enabled, we also need to configure php-fpm. In fact, when installing php, the configuration file of php-fpm has provided us with a configuration file template. The template is/usr/local/etc/php-fpm.conf.default, as follows:

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

Now we only need to copy this file and rename it to the php-fpm.conf, as shown below:

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

To enable the php-fpm service. Copy the/sapi/fpm/init. d. php-fpm file in the php installation directory. As follows:

Cp./sapi/fpm/init. d. php-fpm/etc/init. d/php-fpm

We can also clearly see that the php-fpm file currently has no execution permission. Grant php-fpm execution permission and start php-fpm as follows:

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

/Etc/init. d/php-fpm start

Netstat-tunlp | grep 9000

We can see that php-fpm has started properly.

Note that php-fpm listens to port 9000 by default.

Now configure nginx to support 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;

}

Create the index. php file in the root directory of the nginx website as follows:

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

Start nginx as follows:

/Usr/local/nginx/sbin/nginx

Netstat-tunlp | grep 80

After nginx is started, visit the website as follows:

We can see it clearly. Php has been installed successfully and supports the mysql database. It is also integrated with nginx.

So far. The installation of php5.6 has ended.

Related Article

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.