002.php installation (LNMP)

Source: Internet
Author: User

Build LNMP environment, need to install MySQL first, and then install PHP, and nginx installation sequence does not matter, the connection between Nginx and PHP needs to be manually configured

I. PHP download and configure "installation environment"

[Email protected] ~]# cd/usr/local/src/
[Email protected] src]# wget http://cn2.php.net/distributions/php-5.4.37.tar.bz2

[Email protected] src]# CD php-5.4.37
[Email protected] php-5.4.37]#/configure--prefix=/usr/local/php--with-config-file-path=/usr/local/php/etc-- ENABLE-FPM--with-fpm-user=php-fpm--with-fpm-group=php-fpm--with-mysql=/usr/local/mysql--with-mysql-sock=/tmp/ Mysql.sock--with-libxml-dir--with-gd--with-jpeg-dir--with-png-dir--with-freetype-dir--with-iconv-dir-- With-zlib-dir--with-mcrypt--enable-soap--enable-gd-native-ttf--enable-ftp--enable-mbstring--enable-exif-- Enable-zend-multibyte--disable-ipv6--with-pear--with-curl--with-openssl

Note: 1. --prefix specifying the installation path

2.--with-config-file-path Set the search path for php.ini

3.--with-fpm-user fpm running user, default is nobody

4.--with-fpm-group fpm Run group, default to nobody

5.--with-mysql Specify the installation path for MySQL

6.--with-mysql-sock Specifies where the Mysql.sock program for MySQL monitoring is

7.--with-libxml-dir is used to specify the location where the LIBXML2 library files are installed.

During the period, there will be an error situation:

#错误1:
Configure:error:jpeglib.h not found.
#解决办法:
[email protected] php-5.4.37]# Yum install Libjpeg-turbo-devel

#错误2:
Configure:error:mcrypt.h not found. Please reinstall Libmcrypt.
We need to install the source of Epel first and then go to install

Download and install Epel:
[Email protected] php-5.4.37]# wget www.lishiming.net/data/attachment/forum/epel-release-6-8_32.noarch.rpm
[Email protected] php-5.4.37]# RPM-IVH epel-release-6-8_32.noarch.rpm

Install Libmcrypt:
[email protected] php-5.4.37]# Yum install-y libmcrypt-devel

If there are other errors, the reason is that some packages are not installed, can be resolved by Baidu.

Two. Create User php-fpm

[Email protected] php-5.4.37]# useradd-s/sbin/nologin php-fpm

Three. PHP Compilation and Installation

[[email protected] php-5.4.37]# Make[[email protected] php-5.4.37]# echo $?0[[email protected] php-5.4.37]# make install[ [Email protected] php-5.4.37]# echo $?0

Four. Copy configuration file, startup script, php-fpm.conf configuration file

Copy the configuration file:

[email protected] php-5.4.37]# CP Php.ini-production/usr/local/php/etc/php.ini

Copy startup script:

[email protected] php-5.4.37]# CP SAPI/FPM/INIT.D.PHP-FPM/ETC/INIT.D/PHP-FPM
[Email protected] php-5.4.37]# chmod 755/etc/init.d/php-fpm

Copy the php-fpm.conf configuration file

[Email protected] php-5.4.37]# Cd/usr/local/php/etc/[[email protected] etc]# mv Php-fpm.conf.default php-fpm.conf

Five. Add the PHP service to the system service and set it to boot, start the program

[[email protected] etc]# chkconfig--add php-fpm[[email protected] etc]# chkconfig php-fpm on
[Email protected] etc]#/usr/local/php/sbin/php-fpm-t
[29-jan-2016 04:30:26] Notice:configuration file/usr/local/php/etc/php-fpm.conf Test is successful

[[email protected] etc]#/etc/init.d/php-fpm start
Starting php-fpm Done
[Email protected] etc]#/ETC/INIT.D/PHP-FPM Reload
Reload Service PHP-FPM Done

Note:/usr/local/php/sbin/php-fpm-t can check PHP configuration for errors

View PHP-FPM process Good and listen port number:

[[Email protected] etc]# PS aux |grep php-fpmroot     16343  0.0  0.2  29748  2976?        Ss   04:33   0:00 php-fpm:master process (/usr/local/php/etc/php-fpm.conf)                                                                    php-fpm  16344  0.0  0.2  29748  2648?        S    04:33   0:00 php-fpm:pool www                                                                                                            php-fpm  16345  0.0        0.2 29748 2648? S    04:33   0:00 php-fpm:pool www                                                                                                            root     16349  0.0  0.0   6048   780 pts/0    s+   04:34   0:00 grep--color php-fpm[[email protected] etc]# [[email protected] etc]# NETSTAT-LNP |grep ' PHP-FPM ' TC P        0      0 127.0.0.1:9000              0.0.0.0:*                   LISTEN      16343/php-fpm

Six. php-fpm.conf configuration file

/usr/local/php/etc/php-fpm.conf configuration file and/usr/local/php/etc/php.ini are not the same:

1./usr/local/php/etc/php-fpm.conf is a related configuration for managing PHP-FPM services

2./usr/local/php/etc/php.ini is a global configuration file for PHP

We changed the php-fpm.conf, changed the php-fpm.conf configuration file:

[Global]#PID settings, default in the installation directory of Var/run/php-fpm.pid, it is recommended to openPID =/usr/local/php/var/run/php-Fpm.pid#error log, default in the installation directory of Var/log/php-fpm.logError_log =/usr/local/php/var/log/php-Fpm.log#www is a name of a pool[www]#The FPM listener port, which is the address of the PHP processing in Nginx, is usually the default value. The available formats are: ' Ip:port ', ' Port ', '/path/to/unix/socket '. Each process pool needs to be set.Listen =/tmp/Www.sock#users and groups that start a processuser = php-Fpmgroup= php-FPM#settings allow nobody to also access Www.sockListen.owner =Nobodylisten.group=nobodypm=Dynamic#maximum number of child processesPm.max_children = 50#number of processes at startupPm.start_servers = 20#The minimum number of idle processes is guaranteed, and if the idle process is less than this value, a new child process is createdPm.min_spare_servers = 5#The maximum number of idle processes is guaranteed, which is cleaned if the idle process is greater than this valuePm.max_spare_servers = 35#sets the number of requests for the service before each child process is reborn. It is useful for third-party modules that may have a memory leak. If set to ' 0 ', the request is always accepted. The default value is: 0.Pm.max_requests = 500#sets the Rlimit limit for the file open descriptor. Default: System-defined value the default open handle is 1024, which can be viewed using ulimit-n, ulimit-n 2048 modification. Rlimit_files = 1024

;

002.php installation (LNMP)

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.