Lamp environment-Compile and install PHP-FPM

Source: Internet
Author: User
Tags mcrypt zts

Tag: Compile and install PHP-FPM lamp XCache

Configuring the httpd-2.4.23 php-5.5.38 in FPM mode


First, the installation of Apache and MySQL is the same as the previous part; Please install it according to it;

Refer to compiling and installing lamp http://ljohn.blog.51cto.com/11932290/1863283

Second, compile and install php-5.5.38


1, to resolve the dependency relationship:


After configuring the Yum source (which can be the local system CD), execute the following command:

# yum-y Groupinstall "X Software Development"


If you want to allow the compiled PHP support mcrypt extension, you can download the following RPM packages.

Libmcrypt-2.5.7-5.el5.i386.rpmlibmcrypt-devel-2.5.7-5.el5.i386.rpmmhash-0.9.9-1.el5.centos.i386.rpmmhash-devel-0.9.9-1.el 5.centos.i386.rpm


2. Compile and install php-5.5.38

# tar zxf php-5.5.38.tar.gz# cd php-5.5.38#./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


Note: If you use PHP5.3 or above, you can specify MYSQLND to link to the MySQL database so that you do not need to install the MySQL or MySQL development package first. MYSQLND is available from PHP 5.3 and can be bound to it at compile time (instead of relying on the specific MySQL client library bindings), but it is the default setting starting with PHP 5.4.

#./configure--with-mysql=mysqlnd--with-pdo-mysql=mysqlnd--with-mysqli=mysqlnd
# Make && make Intall
To provide a configuration file for PHP: # mkdir/etc/php5{,.d}# CP Php.ini-production/etc/php5/php.ini


To edit a php-fpm configuration file:

# vim/usr/local/php5/etc/php-fpm.conf Configure FPM related options for the value 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


The next step is to start php-fpm:

# service PHP-FPM Start

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-fpmtcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 689/php-fpm


Third, configuration httpd-2.4.23

# vim/etc/httpd24/httpd.conf

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

LoadModule proxy_module modules/mod_proxy.soloadmodule proxy_fcgi_module modules/mod_proxy_fcgi.so


2. Configuring the central host

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


3, edit Apache configuration file httpd.conf, let Apache can recognize PHP format page, and support the PHP format of the home page

# vim/etc/httpd/httpd.conf 1, add the following two lines AddType application/x-httpd-php. php addtype application/x-httpd-php-source. ph PS 2, positioning to DirectoryIndex index.html modified to: DirectoryIndex index.php index.html

Add: Apache httpd 2.4 Previous versions, either run PHP as an Apache module or add a third-party module to support the PHP-FPM implementation.

Iv. Installing the xcache-3.2.0 Accelerator for PHP

1. Install xcache-3.2.0# tar zxf xcache-3.2.0.tar.gz# cd xcache-3.2.0#/usr/local/php/bin/phpize#./configure--enable-xcache --with-php-config=/usr/local/php5/bin/php-config# make && make install


At the end of the installation, a line similar to the following appears:

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


2, edit php.ini, integrate PHP and XCache:

The sample configuration provided by XCache is first imported into the php.ini# mkdir/etc/php5.d# CP xcache.ini/etc/php5.d


Description: The Xcache.ini file is in the XCache source directory.

Next edit Vim/etc/php5.d/xcache.ini, locate the line that begins with zend_extension, and modify it to the following line: Extension =/usr/local/php5/lib/php/extensions/ No-debug-non-zts-20121212/xcache.so

Restart PHP-FPM service, and HTTPD24 service after configuration is complete

# service PHP-FPM restart# service httpd24 restart


Browser access http://192.168.137.30 Check that the PHP test page is loading the information for the XCache plugin.

Pressure test

# ab-c 20-n http://192.168.137.30/pma/index.php

Up to 5 times times faster than before compared (test reference value)


This article is from the "Ljohn" blog, make sure to keep this source http://ljohn.blog.51cto.com/11932290/1863570

Lamp environment-Compile and install PHP-FPM

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.