(1)下载安装包到/home/proxy/temp/下,然后进行解压操作
apr、apr-util下载地址http://archive.apache.org/dist/apr、http://www.apache.org/dist/apr/
pcre下载地址ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/、http://ftp.pcre.org/pub/pcre/
httpd下载地址https://archive.apache.org/dist/httpd/、http://www.apache.org/dist/httpd/
mod_wl_24.so 下载地址https://www.oracle.com/technetwork/middleware/webtier/downloads/index-jsp-156711.html
tar -zxvf apr-1.4.6.tar.gz
tar -zxvf apr-util-1.5.2.tar.gz
tar -zxvf pcre-8.38.tar.gz
tar -zxvf httpd-2.2.29.tar.gz
如果没有(gcc、gcc-c++、expat-devel、penssl-devel)就安装
yum -y install gcc
yum -y install gcc-c++
yum install expat-devel
yum -y install mod_ssl openssl-devel
(2)编译安装apr
cd apr-1.4.6
./configure --prefix=/home/app/deploy/apr/ #安装在/home/app/deploy下 命名为apr
make
make install
(3)编译安装apr-util
cd apr-util-1.5.2
./configure --prefix=/home/app/deploy/apr-util --with-apr=/home/app/deploy/apr
make
make install
(4) 编译安装pcre
cd pcre-8.38
./configure --prefix=/home/app/deploy/pcre
make
make install
到此为止基本上解决了依赖关系。
(5) 编译安装httpd-2.2.15
cd httpd-2.2.15
./configure --prefix=/home/app/deploy/apache --sysconfdir=/home/app/deploy/apache/conf --enable-so --enable-rewirte --enable-ssl --enable-cgi --enable-cgid --enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all --with-apr=/home/app/deploy/apr --with-apr-util=/home/app/deploy/apr-util
make
make install
注:apache各个版本有差异,如果有问题(./configure --prefix=/home/app/deploy/apache --sysconfdir=/home/app/deploy/apache/conf --enable-so --enable-rewirte --enable-ssl --enable-cgi --enable-cgid --enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all --with-apr=/home/app/deploy/apr --with-apr-util=/home/app/deploy/apr-util --with-pcre=/home/app/deploy/pcre)
解释:
--enable-so:支持动态共享模块,如果支持php将不能与apache一起工作。必须要有
--enable-ssl:启用ssl功能,如果不启用将无法使用https
--enable-mpms-shared=all:prefork、worker、event
--with-mpm=event:event为默认
--enable-rewrite:支持URL重写
--enable-cgi :支持cgi
--enable-cgid:httpd使用event或者worker得启用被线程方式访问
--enable-modules=most :启用大多数模块
--enable-mods-shared=most:启用大多数共享模块
(6) 启动停止服务
启动
/home/app/deploy/apache/bin/httpd -k start -f /home/app/deploy/apache/conf/httpd.conf
停止
/home/app/deploy/apache/bin/httpd -k stop -f /home/app/deploy/apache/conf/httpd.conf
(7) 单独安装可选模块
1. 首先定位到Apache源码的 proxy目录
# cd /home/proxy/temp/httpd-2.2.15
# cd modules/proxy
2. 编译相应模块:
其中 "/home/app/deploy/apache" 为之前Apache的安装目录
# /home/app/deploy/apache/bin/apxs -c -i mod_proxy.c proxy_util.c
加载模块:
# /home/app/deploy/apache/bin/apxs -i -a -n proxy mod_proxy.la
这样,就将proxy安装成功了,你可以到httpd.conf中看到自动添加了如下语句:
LoadModule proxy_module modules/mod_proxy.so
module 文件夹中也生成了相应的 mod_proxy.so 模块
但是,proxy只是核心模块,要具体使用时,还需要增加相应的模块,方法类似。
例如笔者要使用 ProxyPass, ProxyPassReverse,
那么就需要 http,所以继续编译添加如下模块:
# /home/app/deploy/apache/bin/apxs -c mod_proxy_http.c
# /home/app/deploy/apache/bin/apxs -i -a -n proxy_http mod_proxy_http.la
(8)反向代理配置
NameVirtualHost *:8080
<VirtualHost *:8080>
ServerAdmin *****@***.com
DocumentRoot /home/apache/docs/
SSLCertificateFile "/home/apache/crt/server.crt"
SSLCertificateKeyFile "/home/apache/crt/server.key"
ErrorLog /home/apache/logs/http-error.log
CustomLog /home/apache/logs/http.log common
<Directory "/home/apache/docs/">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
SSLEngine On
SSLProxyEngine On
ProxyRequests Off
ProxyPreserveHost On
#https转http
ProxyPass /app/ http://*.*.*.*:8080/app/
ProxyPassReverse /app/ http://*.*.*.*:8080/app/
#https转https
ProxyPass /app/ https://*.*.*.*:8080/app/
ProxyPassReverse /app/ https://*.*.*.*:8080/app/
</VirtualHost>
(9)正向代理配置
NameVirtualHost *:8080
<VirtualHost *:8080>
ServerAdmin *****@***.com
ServerName netconnectapp
DocumentRoot /home/apache/docs/
ServerAlias testapp
ErrorLog /home/apache/logs/http-error.log
CustomLog /home/apache/logs/http.log common
<Directory "/home/apache/docs/">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
#正向代理设置
ProxyRequests On
ProxyVia On
Timeout 30
KeepAlive On
MaxKeepAliveRequests 500
KeepAliveTimeout 30
AllowCONNECT 443 563 5000 80
<Proxy *>
Order Deny,Allow
Deny from all
Allow from all
</Proxy>
</VirtualHost>