This article by show according to Lin Feng to provide friendship sponsorship, starting in the mud 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
Before installing, we need to install the packages that php5.6 compile on. As follows:
Yum-y install gcc gcc-c++ libxml2 libxml2-devel
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
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
If there is no error, after the configuration is complete. The system will appear with the following prompt message:
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
PHP compiled for a long time, depending on the performance of the machine needs to wait about 10-20 minutes. After compiling, the following:
After compiling, we will now start to install PHP, using the following command:
Make install
Once the installation is complete, we can see if the installation was successful with the PHP–V command. As follows:
Php–v
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
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
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
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
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
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;
}
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 ();?>
Now to start Nginx, as follows:
/usr/local/nginx/sbin/nginx
NETSTAT-TUNLP |grep 80
After the Nginx boot is complete, now visit the website as follows:
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