一、安装httpd

1、安装apr

yum -y install gcc gcc-c++ openssl-devel pcre-develtar  xf  apr-1.4.6.tar.bz2cd apr-1.4.6./configure --prefix=/usr/local/apr --disable-ipv6make && make install

2、安装apr-util

tar xf apr-util-1.4.1.tar.bz2cd apr-util-1.4.1./configure  --prefix=/usr/local/apr-util  --with-apr=/usr/local/aprmake && make install

3、安装apache

tar zxf httpd-2.4.17.tar.gz cd httpd-2.4.17./configure \--prefix=/usr/local/apache \--sysconfdir=/etc/httpd \--enable-so \--enable-ssl \--enable-cgi \--enable-rewrite \--with-zlib \--with-pcre \--with-apr=/usr/local/apr \--with-apr-util=/usr/local/apr-util \--enable-modules=most \--enable-mods-shared=most \--enable-mpms-shared=all \--with-mpm=eventmake && make install

4、设置服务控制脚本

cp build/rpm/httpd.init /etc/init.d/httpdvim /etc/init.d/httpd    httpd=${HTTPD-/usr/local/apache/bin/httpd}    pidfile=${PIDFILE-/usr/local/apache/logs/${prog}.pid}    lockfile=${LOCKFILE-/var/lock/subsys/${prog}}    RETVAL=0    # check for 1.3 configuration    check13 () {        CONFFILE=/etc/httpd/httpd.confecho "PATH=/usr/local/apache/bin:$PATH" >> /etc/profile.d/http.sh. /etc/profile.d/http.shln -s /usr/local/apache/include/ /usr/include/httpdvim /etc/httpd/httpd.conf    ServerName localhost:80chkconfig --add httpdchkconfig httpd onservice httpd start

二、安装php

tar zxf php-5.6.0.tar.gzcd php-5.6.0yum install -y libxml2 libxml2-devel bzip2 bzip2-devel curl* curl-devel libjpeg\* openjpeg\* \*png\* freetype\*./configure \--prefix=/usr/local/php \--with-config-file-path=/usr/local/php/etc \--with-bz2 \--with-curl \--enable-ftp \--enable-sockets \--disable-ipv6 \--with-gd \--with-jpeg-dir=/usr/local \--with-png-dir=/usr/local \--with-freetype-dir=/usr/local \--enable-gd-native-ttf \--with-iconv-dir=/usr/local \--enable-mbstring \--enable-calendar \--with-gettext \--with-libxml-dir=/usr/local \--with-zlib \--with-pdo-mysql=mysqlnd \--with-mysqli=mysqlnd \--with-mysql=mysqlnd \--enable-dom \--enable-xml \--enable-fpm \--with-libdir=lib64 \--enable-bcmathmakemake installcp php.ini-production /usr/local/php/etc/php.inicp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.confcp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpmchmod +x /etc/init.d/php-fpm chkconfig --add php-fpmchkconfig php-fpm onservice php-fpm start

三、整合httpd和php

方式1:修改httpd主配置文件httpd.conf

去掉以下两行的 ‘#’LoadModule proxy_module modules/mod_proxy.so  LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so 修改ServerNameServerName 127.0.0.1:80 或 ServerName localhost:80添加
SetHandler "proxy:fcgi://127.0.0.1:9000"

 方式2:配置虚拟主机

去掉以下三行的 ‘#’LoadModule proxy_module modules/mod_proxy.so  LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so Include /etc/httpd/extra/httpd-vhosts.conf修改ServerNameServerName 127.0.0.1:80 或 ServerName localhost:80注释下面正一行DocumentRoot "/usr/local/apache/htdocs"在httpd-vhosts.conf配置文件添加虚拟机
DocumentRoot "/usr/local/apache/htdocs"ServerName www.example.comProxyRequests OffProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/$1
Options noneAllowOverride noneRequire all granted

四、测试

新建测试文件

vim /usr/local/nginx/html/phpinfo.php

在浏览器中输入:http://ip/phpinfo.php