httpd with PHP's FPM mode

Source: Internet
Author: User
Tags fpm mcrypt

httpd2.4 version of the compilation installation, no longer repeat, view previous article: http://www.cnblogs.com/jsonhc/p/7134053.html

Download PHP source bundle from official website: php-5.6.30.tar.bz2

1, install the necessary dependency package

Yum install-y libxml2 libxml2-devel bzip2-devel libjpeg-devel libpng-devel freetype-devel installation: Libmcryptwget ftp://mcrypt . Hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gztar XF LIBMCRYPT-2.5.7.TAR.GZCD libmcrypt-2.5.7./ Configuremake && make install2, unzip and compile execute tar XF php-5.6.30.tar.bz2cd php-5.6.30./configure--prefix=/usr/local/ PHP--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-mcrypt--with-zlib--with-libxml-dir=/usr--enable-xml-- Enable-sockets--ENABLE-FPM--with-config-file-path=/etc--with-config-file-scan-dir=/etc/php.d--with-bz2--with-gdmake && make Install3, add config file, start script #cp PHP.INI-PRODUCTION/ETC/PHP.INI#CP Sapi/fpm/init.d.php-fpm/etc/rc.d/init.d/php-fpm#chmod + X/etc/rc.d/init.d/php-fpm#chkconfig--add php-fpm#chkconfig--list php-fpm Provisioning profile for PHP-FPM: #cp/usr/local/php/etc/ Php-fpm.conf.default/usr/local/php/etc/php-fpm.conf and modify several of these values: Pm.max_children = 50pm.start_servers = 5pm.min_spare_ Servers = 2pm.max_spare_servers = 8

[[Email protected] php-5.6.30]# service PHP-FPM start
Starting php-fpm Done

[Email protected] ~]# NETSTAT-TUNLP
Active Internet connections (only servers)
Proto recv-q send-q Local address Foreign address State Pid/program Name
TCP 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 5104/sshd
TCP 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 27281/php-fpm

4. Modify the httpd configuration file to support PHP

##### #load modules#### enable these two modules
LoadModule Proxy_module modules/mod_proxy.so
LoadModule Proxy_fcgi_module modules/mod_proxy_fcgi.so

##### #添加php:

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

# # # #修改DirectoryIndex:

DirectoryIndex index.html index.php

# # #然后在虚拟主机中配置用fcgi来处理php文件

##### #config fpm####
Proxyrequests OFF
Proxypassmatch ^/(. *\.php) $ fcgi://127.0.0.1:9000/usr/local/apache2.4/www/$1

Proxypassmatch ^/(. *\.php) $ fcgi://ip:9000/path/to/document_root/$1 # 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. Note: Here the document_root is just the path of the PHP file, it can not be httpd site root directory. In real-world environments, PHP-FPM and httpd are located on different hosts, and dynamic resources are deployed on PHP-FPM servers. Due to the httpd compiled installation directory under/usr/local/apache2.4, the default Web site root directory for Htdocs is now checked for success:

[Email protected] apache2.4]# CD htdocs/
[email protected] htdocs]# LL
Total 4
-rw-r--r--. 1 root root ten Jul 14:35 index.html
[email protected] htdocs]# cat index.html
Test page

Access:

The configuration file has just been configured in the Dynamic directory as: Proxypassmatch ^/(. *\.php) $ fcgi://127.0.0.1:9000/usr/local/apache2.4/www/$1

[Email protected] apache2.4]# CD www/
[email protected] www]# LL
Total 4
-rw-r--r--. 1 root root 154 Jul 14:34 index.php
[email protected] www]# cat index.php
<?php
$conn =mysql_connect (' 127.0.0.1 ', ' root ', ' redhat ');
if ($conn)
echo "Successful";
Else
echo "Failure";
Mysql_close ();
Phpinfo ();
?>

Then visit:

So static storage of Web files and dynamically stored PHP files are not directly linked, can be placed casually, of course, it is possible to put together

httpd with PHP's FPM mode

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.