Apache2.4安装以及配置

本文详细介绍如何从零开始安装配置Apache 2.4.23及Tomcat连接器Mod_JK 1.2.42,并实现HTTPS反向代理。涵盖了所需软件包的下载、安装步骤、Apache配置及证书设置等关键环节。
摘要由CSDN通过智能技术生成

一、       需要软件

- gcc

- APR 1.5.2
- APR-Util 1.5.4

- PCRE 8.38

- Zlib 1.2.8

- OpenSSL-1.0.2i

- Apache 2.4.23

- Tomcat Connector JK 1.2.42

 

下载安装包:

wgethttp://apache.fayea.com/apr/apr-1.5.2.tar.gz

wgethttp://apache.fayea.com/apr/apr-util-1.5.4.tar.gz

wgethttp://nchc.dl.sourceforge.net/project/pcre/pcre/8.38/pcre-8.38.tar.gz

wgethttp://zlib.net/zlib-1.2.8.tar.gz

wgethttps://www.openssl.org/source/old/1.0.2/openssl-1.0.2i.tar.gz

wgethttp://apache.fayea.com//httpd/httpd-2.4.23.tar.gz

wgethttp://apache.fayea.com/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.42-src.tar.gz

二、安装步骤

1.    GCC

执行gcc –v查看是否安装。如果没有安装,则yuminstall gcc-c++

2.    Apr

tar -zxvf apr-1.5.2.tar.gz

cd apr-1.5.2

./configure --prefix=/usr/local/apr

make && make install

3.    Apr-util

tar -zxvf apr-util-1.5.4.tar.gz

cd apr-util-1.5.4

./configure --prefix=/usr/local/apr-util--with-apr=/usr/local/apr

make && make install

4.    PCRE

tar -zxvf pcre-8.38.tar.gz

cd pcre-8.38

./configure --prefix=/usr/local/pcre

make && make install

5.    ZLIB

tar -zxvf zlib-1.2.8.tar.gz

cd zlib-1.2.8

CFLAGS="-O3 -fPIC" ./configure

make test

make install

make clean

6.    Openssl(试过1.1.0,但在build apache的时候总有错误)

tar -zxvf openssl-1.0.2i.tar.gz
cd openssl-1.0.2i

./config -fPIC --prefix=/usr/local/openssl--openssldir=/usr/local/openssl
make && make install

7.    Httpd 2.4.23

tar -zxvf httpd-2.4.23.tar.gz
cd httpd-2.4.23

./configure --prefix=/usr/local/apache24--enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib--with-pcre=/usr/local/pcre --with-apr=/usr/local/apr--with-apr-util=/usr/local/apr-util --with-ssl=/usr/local/openssl--enable-modules=most
make && make install

8.    Mod_JK

tar -zxvf tomcat-connectors-1.2.42-src.tar.gz

cd tomcat-connectors-1.2.40-src

cd native

./configure--with-apxs=/usr/local/apache24/bin/apxs

make && make install

 

三、配置Apache

1.    创建workers.properties,内容如下

worker.list=worker1

worker.worker1.port=8009

worker.worker1.host=174.34.64.114

worker.worker1.type=ajp13

wokrer.worker1.lbfactor=1

 

2.    修改httpd.conf

#Secure (SSL/TLS) connections
Include conf/extra/httpd-ssl.conf

*启用Secure (SSL/TLS) connections需要以下模块,确认开头的#已经去掉:
LoadModule log_config_modulemodules/mod_log_config.so

LoadModule setenvif_modulemodules/mod_setenvif.so
LoadModule socache_shmcb_modulemodules/mod_socache_shmcb.so

LoadModule ssl_module modules/mod_ssl.so

 

加入下面内容到httpd.conf

 

TraceEnable off

ServerNameXXXX:80

LoadModule jk_module modules/mod_jk.so

#JkOptions +DisableResue

JkWorkersFile conf/workers.properties

JkLogFile logs/mod_jk.log

JkLogLevel error

#JkMount /IP/* worker1

#JkMount /IPT/* worker1

 

RewriteEngine On

RewriteCond %{HTTPS}  !^on$   [NC]

RewriteRule . https://%{HTTP_HOST}%{REQUEST_URI} [R]

#RewriteCond %{REQUEST_URI} =/IP [OR]

#RewriteCond %{REQUEST_URI} =/IPT

RewriteRule ^(.+[^/])$ $1/ [R]

 

3.    配置HTTPS反向代理

把以下内容加入到<VirtualHost _default_:443>…</ VirtualHost>:

JkMount/IP/* worker1

JkMount/IPT/* worker1

 

RewriteCond%{REQUEST_URI} =/IP [OR]

RewriteCond%{REQUEST_URI} =/IPT

RewriteRule^(.+[^/])$ $1/ [R]

配置证书:

SSLCertificateFile"/usr/local/apache24/conf/ssl.crt/server.crt"

SSLCertificateKeyFile"/usr/local/apache24/conf/ssl.crt/server.key"

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值