httpd結合php的fpm模式
httpd2.4版本的編譯安裝,不再贅述,查看上一篇:http://www.cnblogs.com/jsonhc/p/7134053.html
從官網下載php源碼包:php-5.6.30.tar.bz2
1、安裝必要的依賴包
yum install -y libxml2 libxml2-devel bzip2-devel libjpeg-devel libpng-devel freetype-devel 安裝:libmcrypt wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz tar xf libmcrypt-2.5.7.tar.gz cd libmcrypt-2.5.7 ./configure make && make install 2、解壓縮並編譯執行 tar xf php-5.6.30.tar.bz2 cd 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[[email protected]
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、修改httpd配置文件以支持php
######load 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
[[email protected] apache2.4]# cd htdocs/
[[email protected] htdocs]# ll
total 4
-rw-r--r--. 1 root root 10 Jul 11 14:35 index.html
[[email protected] htdocs]# cat index.html
test page
訪問截圖:
剛剛在配置文件配置的是動態目錄為: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 11 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();
?>
然後訪問截圖:
所以靜態存放的網站文件與動態存放的php文件沒有直接的聯系,可以隨便安放,當然放在一起也是可以的
httpd結合php的fpm模式