前事不忘,后事之师,不忘国耻!

 注册  找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3736|回复: 0

FreeBSD 最小化安装 +diablo-jdk +Apache 与 Tomcat 整合 !

[复制链接]

FreeBSD 最小化安装 +diablo-jdk +Apache 与 Tomcat 整合 !

[复制链接]
ehxz

主题

0

回帖

7251

积分

管理员

积分
7251
2007-5-4 09:02:48 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

×
这篇文章算是补交很久之前的一篇作业,也顺便平息坛子里面很多同学的疑问!

我先说明一下配置环境的大概情况:
OSFreeBSD 6.2-RELEASE
JDKdiablo-jdk-1.5.0.07.01
Apacheapache-2.2.3
Tomcattomcat-5.5.23

具体的版本信息显示如下:

[
root@FreeBSD ~] $ pkg_info
apache-2.2.3    Version 2.2 of Apache web server with prefork MPM.
bash-3.1.17     The GNU Project's Bourne Again SHell
cvsup-without-gui-16.1h_2 General network file distribution system optimized for CVS
diablo-jdk-1.5.0.07.01 Java Development Kit 1.5.0_07.01
expat-2.0.0_1    XML 1.0 parser written in C
fontconfig-2.3.2_6,1 An XML-based font configuration API for X Windows
freetype2-2.2.1_1  A free and portable TrueType font rendering engine
gettext-0.14.5_2  GNU gettext package
gmake-3.81_1    GNU version of 'make' utility
javavmwrapper-2.3  Wrapper script for various Java Virtual Machines
libdrm-2.0.2    Userspace interface to kernel Direct Rendering Module servi
libiconv-1.9.2_2  A character set conversion library
mod_jk-ap2-1.2.21,1 Apache JK module for connecting to Tomcat using AJP1X
perl-5.8.8     Practical Extraction and Report Language
pkg-config-0.21   A utility to retrieve information about installed libraries
tomcat-5.5.23    Open-source Java web server by Apache, 5.5.x branch
xorg-libraries-6.9.0 X11 libraries and headers from X.Org         [/pre]

好,来看看具体的做法吧!

第一步:安装FreeBSD,采取最小化安装的步骤。

这里没有什么特别的地方,只是提醒一下,安装完成后注意要更新到最新的ports tree !

由于是最小化安装,所以需要通过 sysinstall 去把下面几个package安装上(via CD-ROM) :
    cvsup-without-gui   # 更新ports tree 需要
    [/li]perl         # Perl当然是很多地方需要的... ^^!
    [/li]gmake         # 安装mod_jk时需要 [/li][li]bash         # 我不熟C Shell,所以我另外安装了这个
    [/li]
完成安装后,更新ports tree,我使用了cvsup.FreeBSDChina.org 作为镜像!

第二步:安装 JDK -FreeBSD 发布的 JDK 1.5 软件包


罗嗦一句,从源代码编译JDK的时代已经过去了,我是懒人,所以喜欢用pkg_add !

如果你想从ports来编译JDK,可以看看这里:FreeBSD中编译JDK

2.1 下载diablo-jdk的软件包:diablo-jdk-freebsd6.i386.1.5.0.07.01.tbz

2.2 查找diablo-jdk的依赖项:

[root@FreeBSD /usr/ports] $ make search name=diablo-jdk-1.5.0.07.01
Port: diablo-jdk-1.5.0.07.01
Path: /usr/ports/java/diablo-jdk15
Info: Java Development Kit 1.5.0_07.01
Maint: glewis@FreeBSD.org
B-deps: expat-2.0.0_1 fontconfig-2.3.2_6,1 freetype2-2.2.1_1 libdrm-2.0.2 pkg-config-0.21 xorg-libraries-6.9.0
R-deps: expat-2.0.0_1 fontconfig-2.3.2_6,1 freetype2-2.2.1_1 javavmwrapper-2.3 libdrm-2.0.2 pkg-config-0.21 xorg-libraries-6.9.0
WWW: http://www.FreeBSDFoundation.org/downloads/java.shtml
[/pre]

可以看到有如下几个packages需要安装:
    [li]expat-2.0.0_1 [/li][li]fontconfig-2.3.2_6,1 [/li][li]freetype2-2.2.1_1 [/li][li]libdrm-2.0.2 [/li][li]pkg-config-0.21 [/li][li]xorg-libraries-6.9.0 [/li][li]javavmwrapper-2.3 [/li]
2.3 从网络安装diablo-jdk所需要的软件包 (并非ports的编译安装方式)

[
root@FreeBSD ~] $ setenv PACKAGESITE ftp://ftp.freebsdchina.org/pub/F ... 6.2-release/Latest/
[root@FreeBSD ~] $ pkg_add -r expat
[root@FreeBSD ~] $ pkg_add -r freetype
[root@FreeBSD ~] $ pkg_add -r fontconfig
[root@FreeBSD ~] $ pkg_add -r ... 省略 ...
[root@FreeBSD ~] $ pkg_add -r xorg-libraries
[root@FreeBSD ~] $ pkg_add -r javavmwrapper
[/pre]

注意:这里用pkg_add的时候,不带软件包的版本号!

* 有没有Debian/Ubuntu中的apt-get的感觉呀? ^^!

2.4 安装diablo-jdk,直接找到我们下载的jdk软件包文件,用pkg_add添加:

[
root@FreeBSD ~] $ pkg_add diablo-jdk-freebsd6.i386.1.5.0.07.01.tbz
[root@FreeBSD ~] $ /usr/local/diablo-jdk1.5.0/bin/java -version
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build diablo-1.5.0-b01)
Java HotSpot(TM) Client VM (build diablo-1.5.0_07-b01, mixed mode)

[/pre]

提醒:
    [li]安装的时候,会出来SUN的许可协议,同意即可. [/li][li]安装时会说javawmwrapper版本有点高,可以不用理会. [/li]

第三步:安装Tomcat

3.1 抓tomcat的档案下来:

[
root@FreeBSD ~] $ cd /usr/ports/www/tomcat55
[root@FreeBSD tomcat55] $ make
===> Vulnerability check disabled, database not found
=> apache-tomcat-5.5.23.tar.gz doesn't seem to exist in /usr/ports/distfiles/.
=> Attempting to fetch from http://www.apache.org/dist/tomcat/tomcat-5/v5.5.23/bin/.
apache-tomcat-5.5.23.tar.gz          100% of 5837 kB  16 kBps 00m00s
===> Extracting for tomcat-5.5.23
=> MD5 Checksum OK for apache-tomcat-5.5.23.tar.gz.
=> SHA256 Checksum OK for apache-tomcat-5.5.23.tar.gz.
===> Patching for tomcat-5.5.23
Installation settings:
  Destination directory:  /usr/local/tomcat5.5
  Location of JDK:     /usr/local/diablo-jdk1.5.0
  Location of Java port:  java/diablo-jdk15
  Running as (user/group): www/www
  HTTP port:        8180
  Shutdown listener port:  8005
  AJP 1.3 connector port:  8009
  Logfile stdout:      /usr/local/tomcat5.5/logs/stdout.log
  Logfile stderr:      /usr/local/tomcat5.5/logs/stderr.log
===> Applying FreeBSD patches for tomcat-5.5.23
>> Removing unneeded files... [ DONE ]
>> Customizing server.xml... [ DONE ]
===> Configuring for tomcat-5.5.23
[/pre]

3.2 安装tomcat

[root@FreeBSD tomcat55] $ make install
===> Installing for tomcat-5.5.23
===>  tomcat-5.5.23 depends on file: /usr/local/diablo-jdk1.5.0/bin/java - found
===>  Generating temporary packing list
===> Checking if www/tomcat55 already installed
>> Creating destination directory... [ DONE ]
>> Copying files to destination directory...
    Installing local configuration file: /usr/local/tomcat5.5/conf/Catalina/localhost/host-manager.xml
    Installing local configuration file: /usr/local/tomcat5.5/conf/Catalina/localhost/manager.xml
    Installing local configuration file: /usr/local/tomcat5.5/conf/catalina.policy
    Installing local configuration file: /usr/local/tomcat5.5/conf/catalina.properties
    Installing local configuration file: /usr/local/tomcat5.5/conf/context.xml
    Installing local configuration file: /usr/local/tomcat5.5/conf/logging.properties
    Installing local configuration file: /usr/local/tomcat5.5/conf/server-minimal.xml
    Installing local configuration file: /usr/local/tomcat5.5/conf/server.xml
    Installing local configuration file: /usr/local/tomcat5.5/conf/tomcat-users.xml
    Installing local configuration file: /usr/local/tomcat5.5/conf/web.xml
[ DONE ]
>> Creating log files... [ DONE ]
>> Creating symlink to tools.jar... [ DONE ]
[/pre]

第四步:安装Apache Web Server


[root@FreeBSD ~] $ pkg_add -r apache22
Fetching ftp://ftp.freebsdchina.org/pub/F ... est/apache22.tbz...
[/pre]

第五步:Apache Web Server 与 Tomcat 的整合

5.1 必备的组件mod_jk的安装

[root@FreeBSD /usr/ports/www/mod_jk] $ make
===> Vulnerability check disabled, database not found
=> tomcat-connectors-1.2.21-src.tar.gz doesn't seem to exist in /usr/ports/distfiles/.
=> Attempting to fetch from http://www.apache.org/dist/tomca ... /source/jk-1.2.21/.
=> Attempting to fetch from http://www.apache.org/dist/tomca ... /source/jk-1.2.21/.
tomcat-connectors-1.2.21-src.tar.gz      100% of 1303 kB  27 kBps 00m00s
===> Extracting for mod_jk-ap2-1.2.21,1
=> MD5 Checksum OK for tomcat-connectors-1.2.21-src.tar.gz.
=> SHA256 Checksum OK for tomcat-connectors-1.2.21-src.tar.gz.
===> Patching for mod_jk-ap2-1.2.21,1
===> Applying FreeBSD patches for mod_jk-ap2-1.2.21,1
===>  mod_jk-ap2-1.2.21,1 depends on file: /usr/local/sbin/apxs - found
===>  mod_jk-ap2-1.2.21,1 depends on executable in : gmake - found
===>  mod_jk-ap2-1.2.21,1 depends on file: /usr/local/sbin/apxs - found
===> Configuring for mod_jk-ap2-1.2.21,1
...省略 ...
...省略 ...
...省略 ...
Making all in common
gmake[1]: Entering directory `/usr/ports/www/mod_jk/work/tomcat-connectors-1.2.21-src/native/common'
gmake[1]: Nothing to be done for `all'.
gmake[1]: Leaving directory `/usr/ports/www/mod_jk/work/tomcat-connectors-1.2.21-src/native/common'
Making all in apache-2.0
gmake[1]: Entering directory `/usr/ports/www/mod_jk/work/tomcat-connectors-1.2.21-src/native/apache-2.0'
gmake[1]: Nothing to be done for `all'.
gmake[1]: Leaving directory `/usr/ports/www/mod_jk/work/tomcat-connectors-1.2.21-src/native/apache-2.0'

[root@FreeBSD /usr/ports/www/mod_jk] $ make install
[/pre]

5.2 编辑 /usr/local/etc/apache22/httpd.conf 文件,添加如下内容:
   
   LoadModule jk_module libexec/apache/mod_jk.so

5.3 建立文件 /usr/local/etc/apache22/Includes/tomcat-apache.conf ,内容如下:

[root@FreeBSD Includes] $ cat tomcat-apache.conf
JkWorkersFile /usr/local/tomcat5.5/conf/workers.properties

JkLogFile /var/log/mod_jk.log
JkLogLevel info

JkMount /*.jsp ajp13
JkMount /jsp-examples/* ajp13
JkMount /servlets-examples/* ajp13
JkMount /servlet/* ajp13
[/pre]

* JkMount 是把tomcat中的URI与Apache的URI做一个映射,也就是说:
  
  
Apache 中的:http://localhost/jsp-examples/some-jsp-file.js
                    <---- 对应 --->
  Tomcat 中的:http://localhost:<port>/jsp-examples/some-jsp-file.jsp

5.4 创建 mod_jk 的日志文件,并设定其归属的用户和组:

[root@FreeBSD ~] $ touch /var/log/mod_jk.log
[root@FreeBSD ~] $ chown www:www /var/log/mod_jk.log
[/pre]

5.5 建立 /usr/local/tomcat5.5/conf/workers.properties 文件:

[root@FreeBSD ~] $ cat /usr/local/tomcat5.5/conf/workers.properties
workers.tomcat_home=/usr/local/tomcat5.5
workers.java_home=/usr/local/diablo-jdk1.5.0
ps=/
worker.list=ajp12, ajp13
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
[/pre]

5.5 更改 workers.properties 文件归属的用户和组:

[root@FreeBSD ~] $ chown www:www /usr/local/tomcat5.5/conf/workers.properties
[/pre]

5.6 确定 tomcat 配置文件 server.xml 中有开启AJP功能:

  <!-- Define an AJP 1.3 Connector --->              
  <Connector className="org.apache.ajp.tomcat4.Ajp13Connector"  
        port="8009" minProcessors="5" maxProcessors="75"   
        acceptCount="10" debug="0"/>            

* 这段不能被注视掉!

第六步:进行测试

6.1 启动服务


[root@FreeBSD ~] $ /usr/local/etc/rc.d/tomcat55 onestart
Starting tomcat55.

[root@FreeBSD ~] $ /usr/local/etc/rc.d/apache22 onestart
Performing sanity check on apache22 configuration:
Syntax OK
Starting apache22.
[/pre]

6.2 测试

http://localhost/ ---> 出现Apache的信息:It works!
http://localhost/index.jsp ---> 出现Tomcat欢迎页面

这样就说明Apache将JSP的处理交给了Tomcat进行了!

免责申明1、欢迎访问本站,本文内容及相关资源来源于网络,版权归版权方所有!本站原创内容版权归本站所有,请勿转载!
2、本文内容仅代表作者观点,不代表本站立场,作者自负,本站资源仅供学习研究,请勿非法使用,否则后果自负!请下载后24小时内删除!
3、本文内容,包括但不限于源码、文字、图片等,仅供参考。本站不对其安全性,正确性等作出保证。但本站会尽量审核会员发表的内容。
4、如本帖侵犯到任何版权问题,请立即告知本站 ,本站将及时删除并致以最深的歉意!客服邮箱:admin@dbabbs.com
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|DBA论坛中国 ( 鲁ICP备20017503号-2 )

GMT+8, 2024-11-22 17:51 , Processed in 0.138020 second(s), 11 queries , MemCached On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表