install_httpd_php
一、安装httpd
1、安装apr
yum-yinstallgccgcc-c++openssl-develpcre-develtarxfapr-1.4.6.tar.bz2cdapr-1.4.6./configure--prefix=/usr/local/apr--disable-ipv6make&&makeinstall
2、安装apr-util
tarxfapr-util-1.4.1.tar.bz2cdapr-util-1.4.1./configure--prefix=/usr/local/apr-util--with-apr=/usr/local/aprmake&&makeinstall
3、安装apache
tarzxfhttpd-2.4.17.tar.gzcdhttpd-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&&makeinstall
4、设置服务控制脚本
cpbuild/rpm/httpd.init/etc/init.d/httpdvim/etc/init.d/httpdhttpd=${HTTPD-/usr/local/apache/bin/httpd}pidfile=${PIDFILE-/usr/local/apache/logs/${prog}.pid}lockfile=${LOCKFILE-/var/lock/subsys/${prog}}RETVAL=0#checkfor1.3configurationcheck13(){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.confServerNamelocalhost:80chkconfig--addhttpdchkconfighttpdonservicehttpdstart
二、安装php
tarzxfphp-5.6.0.tar.gzcdphp-5.6.0yuminstall-ylibxml2libxml2-develbzip2bzip2-develcurl*curl-devellibjpeg\*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-bcmathmakemakeinstallcpphp.ini-production/usr/local/php/etc/php.inicp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.confcpsapi/fpm/init.d.php-fpm/etc/init.d/php-fpmchmod+x/etc/init.d/php-fpmchkconfig--addphp-fpmchkconfigphp-fpmonservicephp-fpmstart
三、整合httpd和php
方式1:修改httpd主配置文件httpd.conf
去掉以下两行的‘#’LoadModuleproxy_modulemodules/mod_proxy.soLoadModuleproxy_fcgi_modulemodules/mod_proxy_fcgi.so修改ServerNameServerName127.0.0.1:80或ServerNamelocalhost:80添加<FilesMatch\.php$>SetHandler"proxy:fcgi://127.0.0.1:9000"</FilesMatch>
方式2:配置虚拟主机
去掉以下三行的‘#’LoadModuleproxy_modulemodules/mod_proxy.soLoadModuleproxy_fcgi_modulemodules/mod_proxy_fcgi.soInclude/etc/httpd/extra/httpd-vhosts.conf修改ServerNameServerName127.0.0.1:80或ServerNamelocalhost:80注释下面正一行DocumentRoot"/usr/local/apache/htdocs"在httpd-vhosts.conf配置文件添加虚拟机<VirtualHost*:80>DocumentRoot"/usr/local/apache/htdocs"ServerNamewww.example.comProxyRequestsOffProxyPassMatch^/(.*\.php)$fcgi://127.0.0.1:9000/usr/local/apache/htdocs/$1<Directory"/usr/local/apache/htdocs">OptionsnoneAllowOverridenoneRequireallgranted</Directory></VirtualHost>
四、测试
新建测试文件
vim/usr/local/nginx/html/phpinfo.php<?phpphpinfo();?>
在浏览器中输入:http://ip/phpinfo.php
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。