设为首页 收藏本站
查看: 617|回复: 0

[经验分享] 源码编译tomcat

[复制链接]

尚未签到

发表于 2018-11-30 13:01:04 | 显示全部楼层 |阅读模式
  tomcat有三种发现版本,官方默认的有源码包和二进制版本,一些社区或个人开发的rpm版本的包,正常情况下,直接使用二进制版本的,一些特殊的环境或者应用中,我们需要编译符合自己的二进制包,一些大型公司的运维人员会编译适合自己需求的rpm包,放进自己部署的yum仓库中,不管是安装系统还是后期部署都相对简单一些
  

  下面给大家简单的介绍一下把源码包编辑成二进制版本包:
  

      大致步骤如下:
  

1.  安装jdk
2.  安装ant
3.  下载源码包
4.  编译:
4.1:ant download
4.2:ant
4.3:ant –f dist.xml release
4.4: ant -f dist.xml package-tgz
编译完成后在/PATH/output/release/v6.0.37/bin/apache-tomcat-6.0.37.tar.gz 这个包便是我我们需要的软件包,下面具体的操作就像下载二进制版本的包,一般情况下我们直接下载二进制版本的包直接解压即可使用,特殊情况可以自己选择编译  

  我的操作步骤:
  

[root@zonghe tools]# tar zxf apache-tomcat-6.0.37-src.tar.gz
[root@zonghe tools]# cd apache-tomcat-6.0.37-src
[root@zonghe apache-tomcat-6.0.37-src]# ls
bin           build.properties.default  conf      eclipse.classpath  extras.xml  KEYS     NOTICE         RELEASE-PLAN-6.0.txt  RUNNING.txt  test
BUILDING.txt  build.xml                 dist.xml  eclipse.project    java        LICENSE  RELEASE-NOTES  res                   STATUS.txt   webapps
[root@zonghe apache-tomcat-6.0.37-src]# ant download
Buildfile: /tools/apache-tomcat-6.0.37-src/build.xml
build-manifests:
[mkdir] Created dir: /tools/apache-tomcat-6.0.37-src/output/manifests
[copy] Copying 8 files to /tools/apache-tomcat-6.0.37-src/output/manifests
download:
......  省略
[get] Getting: http://downloads.sourceforge.net/nsis/nsis-2.46.zip
[get] To: /usr/share/java/file.zip
[get] http://downloads.sourceforge.net/nsis/nsis-2.46.zip permanently moved to http://downloads.sourceforge.net/project/nsis/NSIS%202/2.46/nsis-2.46.zip
[get] http://downloads.sourceforge.net/project/nsis/NSIS%202/2.46/nsis-2.46.zip moved to http://jaist.dl.sourceforge.net/project/nsis/NSIS%202/2.46/nsis-2.46.zip
[unzip] Expanding: /usr/share/java/file.zip into /usr/share/java
[delete] Deleting: /usr/share/java/file.zip
BUILD SUCCESSFUL
Total time: 1 minute 0 seconds
[root@zonghe apache-tomcat-6.0.37-src]# ant
Buildfile: /tools/apache-tomcat-6.0.37-src/build.xml
build-prepare:
[mkdir] Created dir: /tools/apache-tomcat-6.0.37-src/output/classes
[mkdir] Created dir: /tools/apache-tomcat-6.0.37-src/output/build
[mkdir] Created dir: /tools/apache-tomcat-6.0.37-src/output/build/bin
[mkdir] Created dir: /tools/apache-tomcat-6.0.37-src/output/build/conf
[mkdir] Created dir: /tools/apache-tomcat-6.0.37-src/output/build/lib
[mkdir] Created dir: /tools/apache-tomcat-6.0.37-src/output/build/logs
....
省略
....
[txt2html] Converted 4 files to /tools/apache-tomcat-6.0.37-src/output/build/webapps/examples/jsp/jsp2/tagfiles
[txt2html] Converted 47 files to /tools/apache-tomcat-6.0.37-src/output/build/webapps/examples
[copy] Warning: Could not find file /usr/share/java/tomcat6-deps/dbcp/tomcat-dbcp.jar to copy.
[copy] Copying 1 file to /tools/apache-tomcat-6.0.37-src/output/build/lib
BUILD SUCCESSFUL
Total time: 15 seconds
[root@zonghe apache-tomcat-6.0.37-src]#  ant -f dist.xml release
Buildfile: /tools/apache-tomcat-6.0.37-src/dist.xml
clean:
dist-prepare:
[mkdir] Created dir: /tools/apache-tomcat-6.0.37-src/output/dist
[mkdir] Created dir: /tools/apache-tomcat-6.0.37-src/output/dist/bin
.....
省略
....
at java.lang.ProcessBuilder.start(ProcessBuilder.java:453)
... 23 more
Total time: 1 second
[root@zonghe apache-tomcat-6.0.37-src]# ant -f dist.xml package-tgz
Buildfile: /tools/apache-tomcat-6.0.37-src/dist.xml
package-tgz:
[tar] Building tar: /tools/apache-tomcat-6.0.37-src/output/release/v6.0.37/bin/apache-tomcat-6.0.37.tar.gz
md5sum:
BUILD SUCCESSFUL
Total time: 2 seconds  

  直接贴出配置,可能比较晕,这里我简单的介绍一下吧!
  

      1.下载源码包,解压进入源码包内
          cp build.properties.default build.properties
  我们可以编译此文件,根据自己的意愿更改任何组建设置
      2.执行ant download 下载相关的依赖包,默认下载到/usr/share/java/目录下
  

[root@zonghe java]# cd /usr/share/java/
[root@zonghe java]# ll
total 28
drwxr-xr-x  4 root root 4096 Jul  1 12:28 commons-daemon-1.0.15
drwxr-xr-x  5 root root 4096 Jul  1 12:29 commons-dbcp-1.3-src
drwxr-xr-x  3 root root 4096 Jul  1 12:29 commons-pool-1.5.7-src
drwxr-xr-x  2 root root 4096 Jul  1 12:29 ecj-4.2.2
drwxr-xr-x 10 root root 4096 Jul  1 12:29 nsis-2.46
drwxr-xr-x  3 root root 4096 Jul  1 12:29 tomcat6-deps
drwxr-xr-x  3 root root 4096 Jul  1 12:28 tomcat-native-1.1.27  

   3. 执行ant编译
       编译完成后,会在当前目录下生产一个output目录
  

[root@zonghe apache-tomcat-6.0.37-src]# cd output/
[root@zonghe output]# ll
total 24
drwxr-xr-x  8 root root 4096 Jul  1 12:29 build
drwxr-xr-x  4 root root 4096 Jul  1 12:29 classes
drwxr-xr-x  4 root root 4096 Jul  1 12:30 deployer
drwxr-xr-x 10 root root 4096 Jul  1 12:30 dist
drwxr-xr-x  2 root root 4096 Jul  1 12:30 manifests
drwxr-xr-x  3 root root 4096 Jul  1 12:30 release  

  此时我们再build目录会得到完整的tomcat发现版本
  

[root@zonghe build]# ll
total 24
drwxr-xr-x 2 root root 4096 Jul  1 12:30 bin
drwxr-xr-x 2 root root 4096 Jul  1 12:30 conf
drwxr-xr-x 2 root root 4096 Jul  1 12:30 lib
drwxr-xr-x 2 root root 4096 Jul  1 12:29 logs
drwxr-xr-x 2 root root 4096 Jul  1 12:29 temp
drwxr-xr-x 7 root root 4096 Jul  1 12:30 webapps  

     4.ant–f dist.xml release    这个命令是:Building a release running tests
       5.ant-f dist.xml package-tgz  生成一个压缩包,
  

  





运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-641622-1-1.html 上篇帖子: tomcat 的配置 下篇帖子: tomcat(2)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

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