Introduction to Lamp compilation two, PHP in the form of FPM to work with Apache

Source: Internet
Author: User

The last time I introduced PHP in a modular way to work with Apache, this time to introduce PHP in an FPM way to combine Apache work process!

Compile and install lamp, using the operating system for CentOS 6, IP address: 192.168.1.101;

HTTPd and MARIADB, and XCache for PHP accelerated compilation process has not changed, as the last introduction of the process, there is no more introduction!

Note: Do not know the compilation process of friends, please see the "Lmap compilation Introduction A" What is said!

The following begins the main introduction of PHP compilation!!


Compilation of php-5.4.40

1. Solve the dependency relationship

[email protected] ~]# yum groupinstall-y "Development tools" "Server Platform development" [[email protected] php-5.4.40] # yum install-y libxml2-devel[[email protected] php-5.4.40]# yum install bzip2-devel-y[[email protected] ~]# yum Localin Stall Libmcrypt-2.5.7-1.2.el6.rf.x86_64.rpm[[email protected] ~]# yum Localinstall libmcrypt-devel-2.5.7-1.2.el6.rf.x86_64.rpm


2. Compile and install php-5.4.40

[[email protected] ~]# mkdir /etc/php5[[email protected] ~]# mkdir / etc/php.d[[email protected] ~]# cd php-5.4.40[[email protected] php-5.4.40]#  ./configure --prefix=/usr/local/php5                 //indicates the installation directory--with-mysql=/usr/local/mysql         //Specifies the MySQL installation directory--with-openssl               //using openssl--with-mysqli=/usr/local/mysql/bin/mysql_config  // Another interface for MySQL--enable-mbstring        //supports multibyte strings, Multiple languages use--with-freetype-dir       //a font format directory--with-jpeg-dir           //jpeg Format Files directory--with-png-dir        PNG Format Files directory--with-zlib          //supports compression--with-libxml-dir=/usr        // The XML Library directory--enable-xml           //supports xml--enable-sockets        //Support Socket--enable-fpm       // Focus: Support fpm--with-mcrypt           // Supports encryption and decryption--with-config-file-path=/etc/php5           // PHP configuration file directory--with-config-file-scan-dir=/etc/php.d    //php Secondary profile directory--with-bz2            //supports bz2 compression [[email protected] php-5.4.40]#  Make -j 4[[email protected] php-5.4.40]# make install[[email protected]  php-5.4.40]# cp php.ini-production /etc/php5/php.ini[[email protected]  Php-5.4.40]# cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm[[email protected] php-5.4.40]# chmod +x /etc/rc.d/init.d/php-fpm[[email  protected] php-5.4.40]# chkconfig --add php-fpm[[email protected] php-5.4.40]#  chkconfig php-fpm on[[email protected] php-5.4.40]# chkconfig --list  PHP-FPM provides configuration files for php-fpm: # cp /usr/local/php5/etc/php-fpm.conf.default /usr/local/php5/etc/ php-fpm.conf  Edit php-fpm configuration file: # vim /usr/local/php5/etc/ Php-fpm.conf configure FPM with the relevant options for the value you need and enable the PID file (the last line below):listen = 0.0.0.0:9000              //monitoring IP and Port pm.max_children = 50         pm.start_servers = 5pm.min_spare_servers = 2pm.max_spare_ servers = 5pid = /usr/local/php5/var/run/php-fpm.pid           the next step is to start php-fpm: # service php-fpm start

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/73/A3/wKiom1YCgomDhN6sAAHa3Nwk-tU571.jpg "title=" Qq20150923100704.png "alt=" Wkiom1ycgomdhn6saaha3nwk-tu571.jpg "/>

3, Configuration httpd-2.4

1. Enable the relevant modules of httpd

After Apache HTTPD 2.4 has a module specifically for the implementation of the FASTCGI, this module is mod_proxy_fcgi.so, it is actually as an extension of the mod_proxy.so module, so the two modules are loaded

# vim/etc/httpd24/httpd.conf

LoadModule Proxy_module modules/mod_proxy.so

LoadModule Proxy_fcgi_module modules/mod_proxy_fcgi.so


2, add the following two lines

AddType application/x-httpd-php. php

AddType Application/x-httpd-php-source. Phps


3. Locate to DirectoryIndex index.html

Modified to:

DirectoryIndex index.php index.html


4. Configuration Support using fcgi

Proxyrequests off// off forward proxy

Proxypassmatch ^/(. *\.php) $ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/$1

send a file request ending in. php to the PHP-FPM process, php-fpm need to know at least the directory and URI to run, so the two parameters are indicated directly after fcgi://127.0.0.1:9000, and the other parameters are passed Mod_ The proxy_fcgi.so is encapsulated and does not need to be specified manually.


5. Test whether PHP has been able to work with Apache in an fpm manner

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/73/A3/wKiom1YCgA6BYvIHAANVPkTGnFA364.jpg "title=" Qq20150923104212.png "alt=" Wkiom1ycga6byvihaanvpktgnfa364.jpg "/>

At this point PHP with FPM Way to combine Apche work is finished!!

This article is from the "Bengbengtu" blog, make sure to keep this source http://bengbengtu.blog.51cto.com/9505633/1697587

Introduction to Lamp compilation two, PHP in the form of FPM to work with Apache

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.