LNMP source code compilation installation php-5.5.32 instance

Source: Internet
Author: User
Tags configuration php mcrypt

This article mainly and everyone to share LNMP source code compiled installation php-5.5.32 instance, hope to help everyone.

1 What is CGI

    • The CGI is all called "Universal Gateway Interface" (Common Gateway Interface), for HTTP
      A tool that the server communicates with the program services on other machines, and the CGI program must be running on a network server.

    • The main disadvantage of the traditional CGI interface approach is poor performance, because every time the HTTP server encounters a dynamic program, it needs to perform parsing by restarting the parser, after which the result is returned to the HTTP server. This is almost unusable when dealing with high concurrent accesses, so fastcgi is born. In addition, the traditional CGI interface security is also very poor, it is now very rarely used.

2 What is fastcgi

    • FastCGI is a scalable, high-speed interface for communicating between HTTP servers and dynamic scripting languages (under Linux, the FastCGI interface is the socket, which can be a file socket or an IP socket), The main advantage is separating the dynamic language from the HTTP server. Most popular HTTP servers support fastcgi. including Apache, Nginx, and lighttpd.

    • At the same time, FASTCGI is supported by many scripting languages, and one of the more popular scripting languages is PHP. The FastCGI interface uses the C/s (client/server) architecture, which separates the HTTP server from the script resolution server and initiates one or more scripts to parse the daemon on the script resolution server. When the HTTP server encounters a dynamic program, it can be delivered directly to the fastcgi process to execute, and the resulting results are returned to the browser. This approach allows the HTTP server to handle static requests exclusively, or to return the results of a dynamic script server to the client, which greatly improves the performance of the entire application system.

3 operation Principle of Nginx fastcgi

Nginx does not support direct invocation or parsing of external dynamic programs, and all external programs (including PHP) must be called through the FastCGI interface. FastCGI interface under Linux is the socket, in order to invoke the CGI program, also need a fastcgi wrapper (can be understood as the program used to start another program), the wrapper is bound to a fixed socket, such as a port or file socket. When Nginx sends the CGI request to the socket, through the FastCGI interface, the wrapper receives the request, and then derives a new thread, which invokes the interpreter or the External program processing script to read the returned data; Wrapper the returned data through the FastCGI interface, along the fixed socket to nginx; Finally, Nginx sends the returned data to the client, which is the whole process of nginx+fastcgi. The detailed process is as follows.

4 lnmp PHP (Fastcgi) Service installation Preparation

4.1 Check the installation of Nginx and MySQL

[Root@web01 ~]# netstat-lntup |egrep "nginx|mysql" tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      1568/ mysqld         TCP        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      1694/nginx          [root@web01 ~]# cat/etc/ Redhat-release CentOS Release 6.9 (Final) [root@web01 ~]# uname-r2.6.32-696.el6.x86_64[root@web01 ~]# uname-mx86_64

4.2 Check the Lib libraries required to install PHP

# PHP program in the development and operation will call some such as zlib, GD and other libraries, so you need to confirm whether the Lib library is installed, execute the command as follows:

Rpm-qa zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-develrpm-qa freetype-devel libpng-devel Gd-devel Libcurl-devel Libxslt-devel

Hint: Libjpeg-turbo-devel is the new name of the early Libjpeg-devel, Libcurl-devel is the new name of the early curl-devel.
Each lib will generally have a corresponding "-devel" named Package,the corresponding "-devel" package, the corresponding LIB package will be installed automatically, such as installation of Gd-devel will install GD.

# These LIB libraries are not required to be installed, but they are usually installed in the current enterprise environment. Otherwise, the PHP program runs a problem, such as the verification code cannot be displayed. [Root@web01 ~]# rpm-qa freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel[root@web01 ~]# [Root@web01 ~]# RP M-qa zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-develzlib-devel-1.2.3-29.el6.x86_64# Generally not installed, requires Yum installation under Yum-y install Zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-develyum-y Install Freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel# Check again, found no libiconv-devel this package, need to manually install under [root@web01 tools]# rpm-qa zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-develzlib-devel-1.2.3-29.el6.x86_ 64LIBJPEG-TURBO-DEVEL-1.2.1-3.EL6_5.X86_64LIBXML2-DEVEL-2.7.6-21.EL6_8.1.X86_64[ROOT@WEB01 tools]# Rpm-qa Freetype-devel libpng-devel gd-devel libcurl-devel libxslt-develfreetype-devel-2.3.11-17.el6.x86_ 64libpng-devel-1.2.49-2.el6_7.x86_64libcurl-devel-7.19.7-53.el6_9.x86_64libxslt-devel-1.1.26-2.el6_3.1.x86_ 64GD-DEVEL-2.0.35-11.EL6.X86_64[ROOT@WEB01 ~]# Cd/home/oldboy/tools/[root@web01 tools]# wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz[root@web01 tools]# tar-zxf libiconv-1.14.tar.gz [root@web01 tools]# cd libiconv-1.14[root@web01 libiconv-1.14]#./configure-- PREFIX=/USR/LOCAL/LIBICONV[ROOT@WEB01 libiconv-1.14]# make && make install# install the associated extensions for PHP, you need to install the Epel source first # Install the Libmcrypt library, which is a modular library that uses dynamic loading, which is not a required library, and needs to be used when developing [ROOT@WEB01 tools]# wget-o/etc/yum.repos.d/epel.repo/http/ Mirrors.aliyun.com/repo/epel-6.repo[root@web01 tools]# Yum install-y libmcrypt-devel# install mhash encryption extension Library [ROOT@WEB01 tools] # yum install-y mhash# install mcrypt encryption Extension Library [root@web01 tools]# yum install-y mcrypt# Check [root@web01 tools]# Rpm-qa Libmcrypt MC Rypt mhashmcrypt-2.6.8-10.el6.x86_64libmcrypt-2.5.8-9.el6.x86_64mhash-0.9.9.9-3.el6.x86_64

4.3 getting the PHP package compiled and installed

# get PHP-5.5.32[ROOT@WEB01 tools]# wget http://mirrors.sohu.com/php/php-5.5.32.tar.gz# decompression configuration php[root@web01 tools]# Tar- XF php-5.5.32.tar.gz [root@web01 tools]# cd php-5.5.32# compiled; Notice that the backslash (\) behind each line cannot have any special characters, including spaces #--with-fpm-user=www &-- With-fpm-group=www the www of these two modules is the user created at Nginx installation time./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[root@web01 php-5.5.32]# echo $?0# in MakThe following operations need to be done before the e-install [root@web01 php-5.5.32]# ln-s/APPLICATION/MYSQL/LIB/LIBMYSQLCLIENT.SO.18/USR/LIB64/[ROOT@WEB01 php-5.5.32]# Touch ext/phar/phar.phar[root@web01 php-5.5.32]# vim/etc/ld.so.conf[root@web01 php-5.5.32]# tail-1/etc/ LD.SO.CONF/APPLICATION/MYSQL/LIB/[ROOT@WEB01 php-5.5.32]# ldconfig# makes && make install (Make-j can specify multiple CPUs, In the case of a number of CPUs), the time is relatively long. [Root@web01 php-5.5.32]# make ... Build complete.    Don ' t forget to run ' make test '. # so make finished (wait a long time) [Root@web01 php-5.5.32]# make install......ln-s-F phar.phar/application/php5.5.32/bin/ pharinstalling PDO headers:/application/php5.5.32/include/php/ext/pdo/# Make install complete [root@web01 php-5. 5.32]# ln-s/application/php5.5.32//application/php[root@web01 php-5.5.32]# ls/application/phpbin etc include Lib P HP sbin var[root@web01 php-5.5.32]# ls php.ini*-l-rw-r--r--1 1001 1001 69236 Feb 2 php.ini-development #开发环境的 Configuration file-rw-r--r--1 1001 1001 69266 Feb 2 php.ini-production #生产环境的configuration file [root@web01 php-5.5.32]# cp php.ini-production/application/php/lib/php.ini #php配置文件默认路径 [ROOT@WEB01 php-5.5.32]# CD/APPLICATION/PHP/ETC/[ROOT@WEB01 etc]# cp php-fpm.conf.default PHP-FPM.CONF[ROOT@WEB01 etc]#/application/php/sbin  /PHP-FPM [root@web01 etc]# lsof-i: 9000COMMAND PID USER FD TYPE DEVICE size/off NODE namephp-fpm 15200 root 7u IPV4 127921 0t0 TCP Localhost:cslistener (LISTEN) php-fpm 15201 www 0u IPv4 127921 0t0 TCP Localhost:cslis Tener (LISTEN) php-fpm 15202 www 0u IPv4 127921 0t0 TCP localhost:cslistener (LISTEN) [Root@web01 etc]# ps-ef |g        Rep Php-fpmroot 15200 1 0 21:35?        00:00:00 Php-fpm:master process (/application/php5.5.32/etc/php-fpm.conf) www 15201 15200 0 21:35?        00:00:00 Php-fpm:pool www www 15202 15200 0 21:35? 00:00:00 Php-fpm:pool www root 15205 1668 0 21:35 pts/0 00:00:00 grep php-fpm# so far PHP installation complete

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.