一、安装httpd
1、安装apr
1
2
3
4
5
|
yum -y
install
gcc gcc-c++ openssl-devel pcre-devel
tar
xf apr-1.4.6.
tar
.bz2
cd
apr-1.4.6
.
/configure
--prefix=
/usr/local/apr
--disable-ipv6
make
&&
make
install
|
2、安装apr-util
1
2
3
4
|
tar
xf apr-util-1.4.1.
tar
.bz2
cd
apr-util-1.4.1
.
/configure
--prefix=
/usr/local/apr-util
--with-apr=
/usr/local/apr
make
&&
make
install
|
3、安装apache
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
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=event
make
&&
make
install
|
4、设置服务控制脚本
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
cp
build
/rpm/httpd
.init
/etc/init
.d
/httpd
vim
/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
.conf
echo
"PATH=/usr/local/apache/bin:$PATH"
>>
/etc/profile
.d
/http
.sh
.
/etc/profile
.d
/http
.sh
ln
-s
/usr/local/apache/include/
/usr/include/httpd
vim
/etc/httpd/httpd
.conf
ServerName localhost:80
chkconfig --add httpd
chkconfig httpd on
service httpd start
|
二、安装php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
tar
zxf php-5.6.0.
tar
.gz
cd
php-5.6.0
yum
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
-bcmath
make
make
install
cp
php.ini-production
/usr/local/php/etc/php
.ini
cp
/usr/local/php/etc/php-fpm
.conf.default
/usr/local/php/etc/php-fpm
.conf
cp
sapi
/fpm/init
.d.php-fpm
/etc/init
.d
/php-fpm
chmod
+x
/etc/init
.d
/php-fpm
chkconfig --add php-fpm
chkconfig php-fpm on
service php-fpm start
|
三、整合httpd和php
方式1:修改httpd主配置文件httpd.conf
1
2
3
4
5
6
7
8
9
|
去掉以下两行的 ‘
#’
LoadModule proxy_module modules
/mod_proxy
.so
LoadModule proxy_fcgi_module modules
/mod_proxy_fcgi
.so
修改ServerName
ServerName 127.0.0.1:80 或 ServerName localhost:80
添加
<FilesMatch \.php$>
SetHandler
"proxy:fcgi://127.0.0.1:9000"
<
/FilesMatch
>
|
方式2:配置虚拟主机
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
去掉以下三行的 ‘
#’
LoadModule proxy_module modules
/mod_proxy
.so
LoadModule proxy_fcgi_module modules
/mod_proxy_fcgi
.so
Include
/etc/httpd/extra/httpd-vhosts
.conf
修改ServerName
ServerName 127.0.0.1:80 或 ServerName localhost:80
注释下面正一行
DocumentRoot
"/usr/local/apache/htdocs"
在httpd-vhosts.conf配置文件添加虚拟机
<VirtualHost *:80>
DocumentRoot
"/usr/local/apache/htdocs"
ServerName www.example.com
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi:
//127
.0.0.1:9000
/usr/local/apache/htdocs/
$1
<Directory
"/usr/local/apache/htdocs"
>
Options none
AllowOverride none
Require all granted
<
/Directory
>
<
/VirtualHost
>
|
四、测试
新建测试文件
1
2
3
4
|
vim
/usr/local/nginx/html/phpinfo
.php
<?php
phpinfo();
?>
|
在浏览器中输入:http://ip/phpinfo.php
本文转自1321385590 51CTO博客,原文链接:http://blog.51cto.com/linux10000/1725685,如需转载请自行联系原作者