RedHat 5.2 安装jdk 6和tomcat 7(2)

安装apache-tomcat-7.0.4.tar.gz
[root@javasrv src]# tar zxvf apache-tomcat-7.0.4.tar.gz
[root@javasrv src]# mv apache-tomcat-7.0.4 /usr/local/
[root@javasrv src]# cd ..
[root@javasrv local]# ln -s apache-tomcat-7.0.4/ tomcat
[root@javasrv local]# /usr/local/tomcat/bin/startup.sh //启动tomcat
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr/java/default
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
使用浏览器访问 :8080/,出现tomcat默认页面,说明已经安装成功。
停用tomcat
[root@javasrv local]# /usr/local/tomcat/bin/shutdown.sh

通过源码编译安装apache-tomcat-7.0.4-src.tar.gz
首先需要安装Ant

下载地址:
Install Apache Ant 1.8.x on your computer
wget
[root@javasrv src]# tar jxvf apache-ant-1.8.2-bin.tar.bz2
[root@javasrv src]# cd /usr/local
[root@javasrv local]# ln -s /usr/local/src/apache-ant-1.8.2/ ant
[root@javasrv local]# cd ~
[root@javasrv ~]# more /etc/profile
ANT_HOME=/usr/local/ant
JAVA_HOME=/usr/java/default
PATH=$JAVA_HOME/bin:$ANT_HOME/bin:$ANT_HOME/bin:$PATH
CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$CLASSPATH
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC JAVA_HOME CLASSPATH
[root@javasrv ~]# . /etc/profile
[root@javasrv ~]# ant
Buildfile: build.xml does not exist!
Build failed
执行ant 后,如果不指定配置文件ant会缺省找build.xml这个配置文件
[root@javasrv ~]# ant -version
Apache Ant(TM) version 1.8.2 compiled on December 20 2010
有这个输出就说明ant安装成功了
//ant安装完成
ant的常用命令
ant
ant javadoc
ant extras
ant release
############################################
ant简单示例
[root@javasrv src]# mkdir -p hello-ant/build/classes
[root@javasrv src]# mkdir -p hello-ant/src/main/hello/ant
在hello-ant/src/main/hello/ant/目录下新建HelloAnt.java文件
package hello.ant;
public class HelloAnt{
    public static void main(String[] args){
        System.out.println("hello ant");
        }  
}
在hello-ant/下新建build.xml文件
<?xml version= "1.0" encoding= "GB2312" ?>

<!--   a project,consist of many task group(target)   -->
<project   default= "main"   basedir= ".">

<!--   one task group in a project,Can contain many tasks(task:javac,java...)   -->
        <target   name= "main">
                <!--build-->
                <javac   srcdir= "src\main\hello\ant"   destdir= "build\classes"/>
                <!--run-->
                <java   classname= "hello.ant.HelloAnt">
                        <classpath>
                                <pathelement   path= "build\classes"/>
                        </classpath>
                </java>
        </target>

</project>

运行ant
进入build.xml所在目录
[root@javasrv src]# cd /usr/local/src/hello-ant/
[root@javasrv hello-ant]# ant -file build.xml
Buildfile: /usr/local/src/hello-ant/build.xml

main:
    [javac] /usr/local/src/hello-ant/build.xml:9: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
    [javac] Compiling 1 source file to /usr/local/src/hello-ant/build/classes
     [java] hello ant

BUILD SUCCESSFUL
Total time: 1 second
运行完之后,在build/classes目录下,出现了编译过的文件HelloAnt.class:
build/classes/hello/ant/HelloAnt.class.
######################################################

编译Tomcat
[root@javasrv src]# tar zxvf apache-tomcat-7.0.4-src.tar.gz
[root@javasrv src]# mv apache-tomcat-7.0.4-src /usr/local/
[root@javasrv src]# cd ..
[root@javasrv local]# ln -s apache-tomcat-7.0.4-src/ tomcat
[root@javasrv local]# cd tomcat
[root@javasrv tomcat]# ant
Buildfile: /usr/local/apache-tomcat-7.0.4-src/build.xml

build-prepare:
    [mkdir] Created dir: /usr/local/apache-tomcat-7.0.4-src/output/classes
    [mkdir] Created dir: /usr/local/apache-tomcat-7.0.4-src/output/build
    [mkdir] Created dir: /usr/local/apache-tomcat-7.0.4-src/output/build/bin
    [mkdir] Created dir: /usr/local/apache-tomcat-7.0.4-src/output/build/conf
    [mkdir] Created dir: /usr/local/apache-tomcat-7.0.4-src/output/build/lib
    [mkdir] Created dir: /usr/local/apache-tomcat-7.0.4-src/output/build/logs
    [mkdir] Created dir: /usr/local/apache-tomcat-7.0.4-src/output/build/temp
    [mkdir] Created dir: /usr/local/apache-tomcat-7.0.4-src/output/build/webapps

download-compile:

proxyflags:

setproxy:

testexist:
     [echo] Testing  for /usr/share/java/tomcat-native-1.1.20/tomcat-native.tar.gz

downloadfile:
    [mkdir] Created dir: /usr/share/java/tomcat-native-1.1.20
      [get] Getting:
      [get] To: /usr/share/java/tomcat-native-1.1.20/tomcat-native.tar.gz
proxyflags:

setproxy:

testexist:
     [echo] Testing  for /usr/share/java/commons-daemon-1.0.3/commons-daemon-1.0                                     .3.jar

downloadgz:
      [get] Getting: .                                     3/commons-daemon-1.0.3-bin.tar.gz
      [get] To: /usr/share/java/file.tar.gz
   [gunzip] Expanding /usr/share/java/file.tar.gz to /usr/share/java/file.tar
    [untar] Expanding: /usr/share/java/file.tar into /usr/share/java
   [delete] Deleting: /usr/share/java/file.tar
   [delete] Deleting: /usr/share/java/file.tar.gz

proxyflags:

setproxy:

testexist:
     [echo] Testing  for /usr/share/java/commons-daemon-1.0.3/commons-daemon-1.0                                     .3-native-src.tar.gz

downloadfile:
      [get] Getting:                                      s-daemon-1.0.3-native-src.tar.gz
      [get] To: /usr/share/java/commons-daemon-1.0.3/commons-daemon-1.0.3-native                                     -src.tar.gz

proxyflags:

setproxy:

testexist:
     [echo] Testing  for /usr/share/java/commons-pool-1.5.5-src/build.xml

downloadgz:
      [get] Getting:                                      pool-1.5.5-src.tar.gz
      [get] To: /usr/share/java/file.tar.gz
   [gunzip] Expanding /usr/share/java/file.tar.gz to /usr/share/java/file.tar
    [untar] Expanding: /usr/share/java/file.tar into /usr/share/java
   [delete] Deleting: /usr/share/java/file.tar
   [delete] Deleting: /usr/share/java/file.tar.gz

proxyflags:

setproxy:

testexist:
     [echo] Testing  for /usr/share/java/commons-dbcp-1.4-src/build.xml

downloadgz:
      [get] Getting:                                      dbcp-1.4-src.tar.gz
      [get] To: /usr/share/java/file.tar.gz
   [gunzip] Expanding /usr/share/java/file.tar.gz to /usr/share/java/file.tar
    [untar] Expanding: /usr/share/java/file.tar into /usr/share/java
   [delete] Deleting: /usr/share/java/file.tar
   [delete] Deleting: /usr/share/java/file.tar.gz
    [mkdir] Created dir: /usr/share/java/tomcat7-deps/dbcp

build-prepare:
   [delete] Deleting directory /usr/local/apache-tomcat-7.0.4-src/output/build/t                                     emp
    [mkdir] Created dir: /usr/local/apache-tomcat-7.0.4-src/output/build/temp

build-manifests:
    [mkdir] Created dir: /usr/local/apache-tomcat-7.0.4-src/output/manifests
     [copy] Copying 12 files to /usr/local/apache-tomcat-7.0.4-src/output/manife                                     sts

build-tomcat-dbcp:
     [copy] Copying 68 files to /usr/share/java/tomcat7-deps/dbcp
    [mkdir] Created dir: /usr/share/java/tomcat7-deps/dbcp/src/java/org/apache/t                                     omcat/dbcp
     [move] Moving 64 files to /usr/share/java/tomcat7-deps/dbcp/src/java/org/ap                                     ache/tomcat/dbcp
    [mkdir] Created dir: /usr/share/java/tomcat7-deps/dbcp/classes
    [javac] Compiling 64 source files to /usr/share/java/tomcat7-deps/dbcp/class                                     es
    [javac] Note: Some input files use or override a deprecated API.
    [javac] Note: Recompile with -Xlint:deprecation for details.
    [javac] Note: Some input files use unchecked or unsafe operations.
    [javac] Note: Recompile with -Xlint:unchecked for details.
      [jar] Building jar: /usr/share/java/tomcat7-deps/dbcp/tomcat-dbcp.jar
      [jar] Building jar: /usr/share/java/tomcat7-deps/dbcp/tomcat-dbcp-src.jar

testexist:
     [echo] Testing  for /usr/share/java/ecj-3.6/ecj-3.6.jar

downloadfile-2:
    [mkdir] Created dir: /usr/share/java/ecj-3.6

proxyflags:

setproxy:

trydownload.check:

trydownload:
      [get] Getting:
      [get] To: /usr/share/java/ecj-3.6/ecj-3.6.jar
................
deploy:
     [copy] Copying 1 file to /usr/local/apache-tomcat-7.0.4-src/output/build/bin
     [copy] Copying 1 file to /usr/local/apache-tomcat-7.0.4-src/output/build/bin
     [copy] Copying 1 file to /usr/local/apache-tomcat-7.0.4-src/output/build/bin
     [copy] Copying 1 file to /usr/local/apache-tomcat-7.0.4-src/output/build/bin
     [copy] Copying 16 files to /usr/local/apache-tomcat-7.0.4-src/output/build/bin
     [copy] Copying 7 files to /usr/local/apache-tomcat-7.0.4-src/output/build/conf
     [copy] Copying 224 files to /usr/local/apache-tomcat-7.0.4-src/output/build/webapps
     [copy] Copying 1 file to /usr/local/apache-tomcat-7.0.4-src/output/build/webapps
     [copy] Copying 1 file to /usr/local/apache-tomcat-7.0.4-src/output/build/webapps/ROOT
    [javac] Compiling 50 source files to /usr/local/apache-tomcat-7.0.4-src/output/build/webapps/examples/WEB-INF/classes
    [javac] Compiling 1 source file to /usr/local/apache-tomcat-7.0.4-src/output/build/webapps/examples/jsp/plugin/applet

examples-sources:
[txt2html] Converted 1 file to /usr/local/apache-tomcat-7.0.4-src/output/build/webapps/examples/jsp/jsp2/simpletag
[txt2html] Converted 4 files to /usr/local/apache-tomcat-7.0.4-src/output/build/webapps/examples/jsp/jsp2/simpletag
[txt2html] Converted 5 files to /usr/local/apache-tomcat-7.0.4-src/output/build/webapps/examples/jsp/jsp2/simpletag
[txt2html] Converted 1 file to /usr/local/apache-tomcat-7.0.4-src/output/build/webapps/examples/jsp/jsp2/jspattribute
[txt2html] Converted 4 files to /usr/local/apache-tomcat-7.0.4-src/output/build/webapps/examples/jsp/jsp2/jspattribute
[txt2html] Converted 4 files to /usr/local/apache-tomcat-7.0.4-src/output/build/webapps/examples/jsp/cal
[txt2html] Converted 1 file to /usr/local/apache-tomcat-7.0.4-src/output/build/webapps/examples/jsp/jsptoserv
[txt2html] Converted 1 file to /usr/local/apache-tomcat-7.0.4-src/output/build/webapps/examples/jsp/jsp2/el
[txt2html] Converted 2 files to /usr/local/apache-tomcat-7.0.4-src/output/build/webapps/examples/jsp/jsp2/el
[txt2html] Converted 3 files to /usr/local/apache-tomcat-7.0.4-src/output/build/webapps/examples/jsp/jsp2/el
[txt2html] Converted 1 file to /usr/local/apache-tomcat-7.0.4-src/output/build/webapps/examples/jsp/jsp2/misc
[txt2html] Converted 4 files to /usr/local/apache-tomcat-7.0.4-src/output/build/webapps/examples/jsp/jsp2/tagfiles
[txt2html] Converted 51 files to /usr/local/apache-tomcat-7.0.4-src/output/build/webapps/examples
     [copy] Copying 1 file to /usr/local/apache-tomcat-7.0.4-src/output/build/lib
     [copy] Copying 1 file to /usr/local/apache-tomcat-7.0.4-src/output/build/lib

BUILD SUCCESSFUL
Total time: 4 minutes 54 seconds

编译完成之后生成目录/usr/local/tomcat/output/build/
[root@javasrv local]# /usr/local/tomcat/output/build/bin/startup.sh //启动tomcat
[root@javasrv local]# ls /usr/local/tomcat/output/build/logs
如果生成了日志说明启动成功,有问题查看catalina.out

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wywyfw.html