hopeless-dream

导航

httpd集成tomcat

安装gcc

[root@iZzm446eh1ux98Z pcre-8.44]# yum install gcc gcc-c++

编译安装httpd

下载地址:http://httpd.apache.org/download.cgi#apache24

[root@iZzm446eh1ux98Z packages]# tar xfz httpd-2.4.46.tar.gz -C ../softwares/

安装apr和apr-util

下载地址:http://apr.apache.org/download.cgi#apache24

[root@iZzm446eh1ux98Z packages]# tar xfz apr-1.7.0.tar.gz -C ../softwares/
[root@iZzm446eh1ux98Z packages]# tar xfz apr-util-1.6.1.tar.gz -C ../softwares/
[root@iZzm446eh1ux98Z packages]# cd ../softwares/

 

[root@iZzm446eh1ux98Z softwares]# mv apr-1.7.0/ apr
[root@iZzm446eh1ux98Z softwares]# mv apr-util-1.6.1/ apr-util
[root@iZzm446eh1ux98Z softwares]# mv apr apr-util httpd-2.4.46/srclib/

安装pcre

下载地址:https://ftp.pcre.org/pub/pcre/

[root@iZzm446eh1ux98Z packages]# tar xfz pcre-8.44.tar.gz -C ../softwares/
[root@iZzm446eh1ux98Z packages]# cd ../softwares/
[root@iZzm446eh1ux98Z softwares]# cd pcre-8.44/
[root@iZzm446eh1ux98Z pcre-8.44]# ./configure 
[root@iZzm446eh1ux98Z pcre-8.44]# make && make install

安装apache

[root@iZzm446eh1ux98Z httpd-2.4.46]# ./configure --prefix=/apache2 --with-included-apr --with-pcre=/opt/softwares/pcre-8.44/pcre-config

安装报错

xml/apr_xml.c:35:10: fatal error: expat.h: No such file or directory

解决

[root@iZzm446eh1ux98Z ~]# yum install -y expat-devel*

报错

/opt/softwares/httpd-2.4.46/srclib/apr-util/.libs/libaprutil-1.so: undefined reference to `XML_GetErrorCode'
/opt/softwares/httpd-2.4.46/srclib/apr-util/.libs/libaprutil-1.so: undefined reference to `XML_SetEntityDeclHandler'
/opt/softwares/httpd-2.4.46/srclib/apr-util/.libs/libaprutil-1.so: undefined reference to `XML_ParserCreate'
/opt/softwares/httpd-2.4.46/srclib/apr-util/.libs/libaprutil-1.so: undefined reference to `XML_SetCharacterDataHandler'
/opt/softwares/httpd-2.4.46/srclib/apr-util/.libs/libaprutil-1.so: undefined reference to `XML_ParserFree'
/opt/softwares/httpd-2.4.46/srclib/apr-util/.libs/libaprutil-1.so: undefined reference to `XML_SetUserData'
/opt/softwares/httpd-2.4.46/srclib/apr-util/.libs/libaprutil-1.so: undefined reference to `XML_StopParser'
/opt/softwares/httpd-2.4.46/srclib/apr-util/.libs/libaprutil-1.so: undefined reference to `XML_Parse'
/opt/softwares/httpd-2.4.46/srclib/apr-util/.libs/libaprutil-1.so: undefined reference to `XML_ErrorString'
/opt/softwares/httpd-2.4.46/srclib/apr-util/.libs/libaprutil-1.so: undefined reference to `XML_SetElementHandler'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:48: htpasswd] Error 1
make[2]: Leaving directory '/opt/softwares/httpd-2.4.46/support'
make[1]: *** [/opt/softwares/httpd-2.4.46/build/rules.mk:75: all-recursive] Error 1
make[1]: Leaving directory '/opt/softwares/httpd-2.4.46/support'
make: *** [/opt/softwares/httpd-2.4.46/build/rules.mk:75: all-recursive] Error 1

解决:重新编译httpd

[root@iZzm446eh1ux98Z httpd-2.4.46]# ./configure --prefix=/apache2 --with-included-apr --with-pcre=/opt/softwares/pcre-8.44/pcre-config

[root@iZzm446eh1ux98Z httpd-2.4.46]# make && make install

Installing configuration files
mkdir /apache2/conf
mkdir /apache2/conf/extra
mkdir /apache2/conf/original
mkdir /apache2/conf/original/extra
Installing HTML documents
mkdir /apache2/htdocs
Installing error documents
mkdir /apache2/error
Installing icons
mkdir /apache2/icons
mkdir /apache2/logs
Installing CGIs
mkdir /apache2/cgi-bin
Installing header files
Installing build system files
Installing man pages and online manual
mkdir /apache2/man
mkdir /apache2/man/man1
mkdir /apache2/man/man8
mkdir /apache2/manual
make[1]: Leaving directory '/opt/softwares/httpd-2.4.46'

启动httpd

[root@iZzm446eh1ux98Z httpd-2.4.46]# /apache2/bin/apachectl -k start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.201.88. Set the 'ServerName' directive globally to suppress this message

这个报错没有关系,也可以按提示修改ServerName

安装mod_jk

Apache通过两种方式与Tomcat集成:mod_jk和mod_proxy_ajp。一下介绍mod_jk

windows下载和安装

下载地址:http://tomcat.apache.org/download-connectors.cgi

下载后将压缩包中的mod_jk.so文件复制到Apache安装目录下的modules下即可。

Linux安装

[root@iZzm446eh1ux98Z packages]# tar xfz tomcat-connectors-1.2.48-src.tar.gz -C ../softwares/
[root@iZzm446eh1ux98Z packages]# cd ../softwares/tomcat-connectors-1.2.48-src/native/

[root@iZzm446eh1ux98Z native]# ./configure --with-apxs=/apache2/bin/apxs

[root@iZzm446eh1ux98Z native]# make

安装后可以在native/apache-2.0目录下找到mod_jk.so文件,将其拷贝到Apache安装路径下的modules目录下即可

[root@iZzm446eh1ux98Z native]# ll apache-2.0/
total 4916
-rw-r--r-- 1 root bin    10350 Feb 21  2020 bldjk54.qclsrc
-rw-r--r-- 1 root bin     9541 Feb 21  2020 bldjk.qclsrc
-rw-r--r-- 1 root bin     1335 Feb 21  2020 config.m4
-rw-r--r-- 1 root root    3153 Sep 12 22:52 Makefile
-rw-r--r-- 1 root root    1462 Sep 12 22:52 Makefile.apxs
-rw-r--r-- 1 root bin     1434 Feb 21  2020 Makefile.apxs.in
-rw-r--r-- 1 root bin     3068 Feb 21  2020 Makefile.in
-rw-r--r-- 1 root bin     6947 Feb 21  2020 Makefile.vc
-rw-r--r-- 1 root root 2822650 Sep 12 22:54 mod_jk.a
-rw-r--r-- 1 root bin   146861 Feb 21  2020 mod_jk.c
-rw-r--r-- 1 root root     911 Sep 12 22:54 mod_jk.la
-rw-r--r-- 1 root root     270 Sep 12 22:54 mod_jk.lo
-rw-r--r-- 1 root root  329584 Sep 12 22:54 mod_jk.o
-rwxr-xr-x 1 root root 1666080 Sep 12 22:54 mod_jk.so

[root@iZzm446eh1ux98Z native]# cp apache-2.0/mod_jk.so /apache2/modules/

配置workers.properties文件

该文件用于描述与Apache集成的Tomcat实例信息,mod_jk依据该文件加载并初始化Servlet容器适配器库,以便进行请求处理

一个worker表示一个Tomcat实例。

[root@iZzm446eh1ux98Z conf]# vim /apache2/conf/worker.properties
worker.list=worker1,worker2
# worker1的配置信息
worker.worker1.port=8009
worker.worker1.host=localhost
worker.worker1.port=ajp13
# worker2的配置信息
worker.worker2.port=8109
worker.worker2.host=localhost
worker.worker2.port=ajp13

 

posted on 2020-09-18 18:57  hopeless-dream  阅读(254)  评论(0编辑  收藏  举报