I. FastCGI
The Fast Universal Gateway Interface (socket) is supported by the general Web program for the HTTP server to communicate with the program services on other machines.
LNMP operation process and analytic principle
Principle Vernacular
用户访问NginxWeb服务器-Ngixn负责解析静态数据(jpg,gif,css,js,avi,html)也接受动态数据(.php)动态数据通过FastCGI接口后抛(fastcgi_pass监听 http://x.x.x.x:9000)给PHP服务器(php-fpm多个进程监听9000端口)[进程配置文件php-fpm.conf设置进程数量]监听到请求就会调用wrapper程序,wrapper会再启多个线程调用PHP解析器(引擎)进行解析,如要连数据库则向后数据库(dbip,root.pass.port3306)进行请求.数据库再将数据通过FastCGI将数据发给Nginx服务器后,Nginx再给用户
Make sure Nginx is started with the database
[[email protected] ~]# netstat -tunlp|egrep "3306|80"tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1657/mysqld tcp 0 0 0.0.0.0:80
Check what PHP requires; Lib Library
[[email protected] ~]# rpm -qa zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel freetype-devel libpng-devel gd-devel libcurl-devel libjpeg-turbo-devel-1.2.1-3.el6_5.x86_64libpng-devel-1.2.49-2.el6_7.x86_64freetype-devel-2.3.11-17.el6.x86_64gd-devel-2.0.35-11.el6.x86_64libcurl-devel-7.19.7-53.el6_9.x86_64zlib-devel-1.2.3-29.el6.x86_64libxml2-devel-2.7.6-21.el6_8.1.x86_64
Update Bash Source
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
Update Epel Source
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
Yum installing LIB libraries and hashing programs
yum install -y zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libmcrypt-devel yum install -y mcrypt mhash
cd /home/oldboy/tools/wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gztar zxf libiconv-1.14.tar.gzcd libiconv-1.14./configure --prefix=/usr/local/libiconv
Centos7 need to operate as follows
cd srclib/sed -i -e ‘/gets is a security/d‘ ./stdio.in.h|make &&make install
Re-confirm that the base library and the extension library are fully installed
[[email protected] tools]# rpm -qa zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libmcrypt-devel mcrypt mhashlibxslt-devel-1.1.26-2.el6_3.1.x86_64mhash-0.9.9.9-3.el6.x86_64libjpeg-turbo-devel-1.2.1-3.el6_5.x86_64libmcrypt-devel-2.5.8-9.el6.x86_64libpng-devel-1.2.49-2.el6_7.x86_64freetype-devel-2.3.11-17.el6.x86_64gd-devel-2.0.35-11.el6.x86_64libcurl-devel-7.19.7-53.el6_9.x86_64zlib-devel-1.2.3-29.el6.x86_64libxml2-devel-2.7.6-21.el6_8.1.x86_64mcrypt-2.6.8-10.el6.x86_64
Take a step at a check
- PHP installation *
http://mirrors.sohu.com/php/
- PHP Installation Parameters *
./configure --prefix=/application/php5.5.32 \--with-mysql=/application/mysql/ \--with-pdo-mysql=mysqlnd \--with-iconv-dir=/usr/local/libiconv \--with-freetype-dir \--with-jpeg-dir \--with-png-dir \--with-zlib \--with-libxml-dir=/usr \--enable-xml \--disable-rpath \--enable-bcmath \--enable-shmop \--enable-sysvsem \--enable-inline-optimization \--with-curl \--enable-mbregex \--enable-fpm \--enable-mbstring \--with-mcrypt \--with-gd \--with-openssl \--with-mhash \--enable-gd-native-ttf \--enable-pcntl \--enable-sockets \--with-xmlrpc \--enable-soap \--enable-short-tags \--enable-static \--with-xsl \--with-fpm-user=www \--with-fpm-group=www \--enable-ftp \--enable-opcache=no
[Email protected] php-5.5.32]# ln-s/application/mysql/lib/libmysqlclient.so.18/usr/lib64/
[email protected] php-5.5.32]# Touch Ext/phar/phar.phar
Compile
[[email protected] php-5.5.32]#make && make install
[[email protected] php-5.5.32]# ln -s /application/php5.5.32/ /application/php
Setting the PHP-FPM master configuration file
[email protected] php-5.5.32]# CP Php.ini-production/application/php/lib/php.ini
[Email protected] php5.5.32]# cd/application/php/etc/
[email protected] etc]# CP Php-fpm.conf.default php-fpm.conf
[Email protected] ~]#/APPLICATION/PHP/SBIN/PHP-FPM
[[email protected] ~]# lsof-i: 9000
COMMAND PID USER FD TYPE DEVICE size/off NODE NAME
PHP-FPM 30476 root 7u IPv4 155336 0t0 TCP localhost:cslistener (LISTEN)
PHP-FPM 30477 www 0u IPv4 155336 0t0 TCP localhost:cslistener (LISTEN)
PHP-FPM 30478 www 0u IPv4 155336 0t0 TCP localhost:cslistener (LISTEN)
[Email protected] ~]# netstat-tunlp|grep "PHP-FPM"
TCP 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 30476/php-fpm
LNMP source code compilation and installation of PHP-5.5.32