Lamp compiled and installed PHP in FPM to work with Apache

Source: Internet
Author: User
Tags mcrypt zts

The previous blog post describes how to build a lamp in the way of compiling, here I am no longer one by one description, I here in detail about PHP in the way of FPM work:

If you want to let the compiled PHP support MCrypt extension, here in addition to libmcrypt this package also need to install

Mhash-0.9.9.9-3.el6.x86_64

Mhash-devel-0.9.9.9-3.el6.x86_64

[[email protected] tmp]# tar xf   Php-5.4.40.tar.bz2 [[email protected] tmp]# cd php-5.4.40[[email protected]  php-5.4.40]# ./configure --prefix=/usr/local/php5 --with-mysql=/usr/local/mysql -- with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring -- with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr - -enable-xml  --enable-sockets --enable-fpm --with-mcrypt  -- with-config-file-path=/etc/php5 --with-config-file-scan-dir=/etc/php5.d --with-bz2[[email  Protected] php-5.4.40]# make -j 4 && make install 
--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 the      //mysql--enable-mbstring                                 //supports multibyte strings and uses--with-freetype-dir        in multiple languages                         //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                            //xml's Library directory--enable-xml                                  //Support 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/php5.d              //PHP auxiliary configuration file directory--with-bz2                                     //supports BZ2 compression
[[EMAIL PROTECTED] PHP-5.4.40]# MKDIR /ETC/PHP5 provides a configuration file for PHP [[email protected]  Php-5.4.40]# cp php.ini-production /etc/php5/php.ini provides a sysv init script for php-fpm and adds it to the list of services: [[ 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-fpmphp-fpm        0:off1:off2:on3:on4:on5:on6:off provides configuration files for PHP-FPM, and edit the php-fpm configuration file [[Email protected] php-5.4.40]# cp /usr/local/php5/etc/php-fpm.conf.default  /usr/local/php5/etc/php-fpm.conf [[email protected] php-5.4.40]# vim /usr/local /php5/etc/php-fpm.conf Configuring the FPThe relevant options for m are the values you need and enable the PID file (the last line below): Pm.max_children = 50pm.start_servers = 5pm.min_spare_ Servers = 2pm.max_spare_servers = 8pid = /usr/local/php5/var/run/php-fpm.pid  [[email protected] php-5.4.40]# service php-fpm startstarting php-fpm   done  ## #说明PHP已经启动起来

Use the following command to verify if the command output has several PHP-FPM processes that indicate that the boot was successful:

# PS aux | grep php-fpm


By default, FPM listens on port 9000 of 127.0.0.1, and can also use the following command to verify that it is already listening on the appropriate socket.

# NETSTAT-TNLP | grep php-fpm

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/73/E7/wKioL1YKBVLD9ph0AAMa6oqypss497.jpg "title=" 120. PNG "alt=" wkiol1ykbvld9ph0aama6oqypss497.jpg "/>

Enabling the relevant modules for 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

LoadModule Proxy_module modules/mod_proxy.so

LoadModule proxy_fcgi_module modules/mod_proxy_fcgi. So

Configure the virtual host to support the use of fcgi

We will add the following in the hub host:

proxyrequests off//off forward proxy

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

Proxyrequests off: Turn off the forward proxy

Proxypassmatch: Send a file request ending in. php to the PHP-FPM process, php-fpm need to know at least the directory and URI that is running, so this is where the two parameters are indicated directly after the fcgi://127.0.0.1:9000. The delivery of other parameters has been encapsulated by mod_proxy_fcgi.so and does not need to be specified manually.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/73/EA/wKiom1YKFdLRGm88AAKWVectULE418.jpg "title=" 130. PNG "alt=" wkiom1ykfdlrgm88aakwvectule418.jpg "/>

It is possible to know that the compilation was successful.

Then we do stress tests:

[Email protected] ~]# ab-c 500-n 10000 HTTP://192.168.1.104/PMA

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/73/E8/wKioL1YKGZ2Cva9fAAIdztWu2GQ878.jpg "title=" 1111. PNG "alt=" wkiol1ykgz2cva9faaidztwu2gq878.jpg "/>

Next we compile the XCache:

[Email protected] tmp]# TAR-XF xcache-3.1.2.tar.gz [[email protected] tmp]# CD Xcache-3.1.2[[email protected] xcache-3.1 .2]#/usr/local/php5/bin/phpphp php-cgi php-config phpize [[email protected] xcache-3.1.2]#/usr/local/p   Hp5/bin/phpize Configuring for:php API Version:20100412zend Module API no:20100525zend Extension API No: 220100525[[email protected] xcache-3.1.2]#./configure--enable-xcache--with-php-config=/usr/local/php5/bin/ Php-configmake && make Install

Compile Build

Installing Shared extensions:/usr/local/php5/lib/php/extensions/no-debug-non-zts-20100525/

[

[email protected] xcache-3.1.2]# CP xcache.ini/etc/php5.d/[[email protected] xcache-3.1.2]# Vim/etc/php5.d/xcache.ini Extension =/usr/local/php5/lib/php/extensions/no-debug-non-zts-20100525/xcache.so The path here is generated by the above compilation [[email protected ] xcache-3.1.2]# service php-fpm Restart # #这里只要重启php就可以了Gracefully shutting down php-fpm. Donestarting PHP-FPM Done

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/73/EB/wKiom1YKIQTj0kuUAAKk6BwvBkY589.jpg "title=" 245. PNG "alt=" wkiom1ykiqtj0kuuaakk6bwvbky589.jpg "/>

It's xcache here. We are doing stress tests: (The address here is random, in the intermittent network, you know)

[Email protected] ~]# ab-c 500-n 10000 HTTP://192.168.1.106/PMA

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/73/EC/wKiom1YKJPbQr18ZAALtOWlBYw0843.jpg "title=" 11111. PNG "alt=" wkiom1ykjpbqr18zaaltowlbyw0843.jpg "/>

It can be seen that the acceleration effect is obvious.

This article is from the "Blank grid" blog, so be sure to keep this source http://lirui213.blog.51cto.com/4449582/1699106

Lamp compiled and installed PHP in 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.