JDK+Tomcat+Jenkins部署

1.Tomcat简介
    Tomcat是Apache软件基金会(Apache Software Foundation)的Jakarta 项目中的一个核心项目,由Apache、Sun和其他一些公司及个人共同开发而成。
    Tomcat服务器是一个免费的开放源代码的Web应用服务器,属于轻量级应用服务器,在中小型系统和并发访问用户不是很多的场合下被普遍使用,是开发和调试
JSP程序的首选。
    Tomcat和Nginx、Apache(httpd)、lighttpd等Web服务器一样,具有处理HTML页面的功能,另外它还是一个Servlet和JSP容器,独立的Servlet容器是
Tomcat的默认模式。不过,Tomcat处理静态HTML的能力不如Nginx/Apache服务器。
  
2.Tomcat安装
    2.1软件准备

JDK下载:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
            Tomcat下载:http://tomcat.apache.org/
            Jenkins下载:https://jenkins.io/index.html

2.2 部署java和tomcat环境

2.2.1将下载的jdk和tomcat源码包解压到/usr/local/include/下
                        tar -zxvf apache-tomcat-8.0.27.tar.gz -C /usr/local/include/tomcat8     #同理解压JDK
                2.2.2在/etc/profile末尾添加如下代码,修改完后执行source /etc/profile,使配置文件立即生效
                        export JAVA_HOME=/usr/local/include/jdk/
                        export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
                        export TOMCAT_HOME=/usr/local/include/tomcat8/
                        export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar
    2.3 Tomcat目录介绍

.
                        ├── bin         #→用以启动、关闭Tomcat或者其它功能的脚本(.bat文件和.sh文件)
                        ├── conf        #→用以配置Tomcat的XML及DTD文件
                        ├── lib         #→存放web应用能访问的JAR包
                        ├── LICENSE
                        ├── logs        #→Catalina和其它Web应用程序的日志文件
                        ├── NOTICE
                        ├── RELEASE-NOTES
                        ├── RUNNING.txt
                        ├── temp        #→临时文件
                        ├── webapps     #→Web应用程序根目录
                        └── work        #→用以产生有JSP编译出的Servlet的.java和.class文件
                        7 directories, 4 files
    2.4 webapps目录结构
                        [[email protected] tomcat]# cd webapps/
                        [[email protected] webapps]# ll
                        total 20
                        drwxr-xr-x 14 root root 4096 Oct  5 12:09 docs     #→tomcat帮助文档
                        drwxr-xr-x  6 root root 4096 Oct  5 12:09 examples #→web应用实例
                        drwxr-xr-x  5 root root 4096 Oct  5 12:09 host-manager #→管理
                        drwxr-xr-x  5 root root 4096 Oct  5 12:09 manager  #→管理
                        drwxr-xr-x  3 root root 4096 Oct  5 12:09 ROOT     #→默认网站根目录
    2.5 启动Tomcat(也可直接使用/usr/local/include/tomcat8/bin/catalina.sh start|stop)

启动程序: /usr/local/include/tomcat8/bin/startup.sh
        关闭程序: /usr/local/include/tomcat8/bin/shutdown.sh

[[email protected] ~]# /application/tomcat/bin/startup.sh
                        Using CATALINA_BASE:   /application/tomcat
                        Using CATALINA_HOME:   /application/tomcat
                        Using CATALINA_TMPDIR: /application/tomcat/temp
                        Using JRE_HOME:        /application/jdk
                        Using CLASSPATH:       /application/tomcat/bin/bootstrap.jar:/application/tomcat/bin/tomcat-juli.jar
                        Tomcat started.
        查看监听端口

[[email protected] tomcat8]#  netstat -tunlp|grep java
                        tcp        0      0 :::8009                     :::*                        LISTEN      1914/java          
                        tcp        0      0 :::80                       :::*                        LISTEN      1914/java         
        查看进程

[[email protected] tomcat8]# ps -ef|grep java
root      1914     1 13 23:08 pts/0    00:00:19 /usr/local/include/jdk//bin/java -Djava.util.logging.config.file=/usr/local/include/tomcat8//conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -classpath /usr/local/include/tomcat8//bin/bootstrap.jar:/usr/local/include/tomcat8//bin/tomcat-juli.jar -Dcatalina.base=/usr/local/include/tomcat8/ -Dcatalina.home=/usr/local/include/tomcat8/ -Djava.io.tmpdir=/usr/local/include/tomcat8//temp org.apache.catalina.startup.Bootstrap start

2.6 访问网站

网址:http://192.168.100.81:8080/           #服务器IP地址
    2.7 Tomcat日志

tomcat实时日志查看

[[email protected] tomcat8]# tailf /usr/local/include/tomcat8/logs/catalina.out
22-Apr-2017 23:08:29.659 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/include/tomcat8/webapps/host-manager has finished in 44 ms
22-Apr-2017 23:08:29.663 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/include/tomcat8/webapps/ROOT
22-Apr-2017 23:08:29.690 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/include/tomcat8/webapps/ROOT has finished in 27 ms
22-Apr-2017 23:08:29.691 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/include/tomcat8/webapps/examples
22-Apr-2017 23:08:29.954 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/include/tomcat8/webapps/examples has finished in 259 ms
22-Apr-2017 23:08:29.955 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /usr/local/include/tomcat8/webapps/manager
22-Apr-2017 23:08:29.982 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /usr/local/include/tomcat8/webapps/manager has finished in 27 ms
22-Apr-2017 23:08:29.990 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-80"]
22-Apr-2017 23:08:30.019 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
22-Apr-2017 23:08:30.036 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 26300 ms

3.Tomcat配置文件
    3.1 Tomcat配置文件介绍

[[email protected] tomcat8]# ll /usr/local/include/tomcat8/conf/
            total 228
            drwxr-x--- 3 root root   4096 Apr 22 15:00 Catalina
            -rwxr-xr-x 1 root root  12895 Apr 13 20:58 catalina.policy
            -rwxr-xr-x 1 root root   7376 Apr 13 20:58 catalina.properties
            -rwxr-xr-x 1 root root   1338 Apr 22 21:41 context.xml
            -rwxr-xr-x 1 root root   1149 Apr 13 20:58 jaspic-providers.xml
            -rwxr-xr-x 1 root root   2358 Apr 13 20:58 jaspic-providers.xsd
            -rwxr-xr-x 1 root root   3622 Apr 13 20:58 logging.properties
            -rwxr-xr-x 1 root root   7509 Apr 22 15:05 server.xml               #→主配置文件
            -rwxr-xr-x 1 root root   2298 Apr 22 22:10 tomcat-users.xml         #→Tomcat管理用户配置文件
            -rwxr-xr-x 1 root root   2633 Apr 13 20:58 tomcat-users.xsd
            -rwxr-xr-x 1 root root 168133 Apr 13 20:58 web.xml
 
    3.2 Tomcat配置管理界面(注意:测试功能,生产环境不要用。)
    
            Tomcat管理功能用于对Tomcat自身以及部署在Tomcat上的应用进行管理的web应用。在默认情况下是处于禁用状态的。如果需要开启这个功能,就需要配置管理用户,即配置上面提到的tomcat-users.xml。

配置tomcat-users.xml文件
 
            [[email protected] tomcat8]# vim /usr/local/include/tomcat8/conf/tomcat-users.xml
            …………
            <role rolename="admin-gui"/>
            <role rolename="manager-gui"/>
            <role rolename="manager-status"/>
            <role rolename="manager-script"/>
            <role rolename="manager-jmx"/>
            <user username="tomcatadmin" password="Foxconn99" roles="admin-gui,manager-gui,manager-status,manager-script,manager-jmx" />
            </tomcat-users>  #在此行前加入上面六行

配置完后,重新启动tomcat服务生效
                [[email protected] ~]# /usr/local/include/tomcat8/bin/shutdown.sh
                [[email protected] ~]# /usr/local/include/tomcat8/bin/startup.sh

配置context.xml文件

[[email protected] conf]# find / -name context.xml
                /usr/local/include/tomcat8/webapps/host-manager/META-INF/context.xml    #修改访问IP列表
                /usr/local/include/tomcat8/webapps/manager/META-INF/context.xml         #修改访问IP列表
                /usr/local/include/tomcat8/conf/context.xml     #此处不用修改
 
             修改/usr/local/include/tomcat8/webapps/host-manager/META-INF/context.xml,添加“192.\d+.\d+.\d+”代表可远程访问该服务器的IP地址段,192...*(此处注意正则表达式)
 
                [[email protected] conf]# vim /usr/local/include/tomcat8/webapps/host-manager/META-INF/context.xml
                <?xml version="1.0" encoding="UTF-8"?>
                <Context antiResourceLocking="false" privileged="true" >
                <Valve className="org.apache.catalina.valves.RemoteAddrValve"
                             allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1|192\.\d+\.\d+\.\d+" />
                </Context>
 
            修改/usr/local/include/tomcat8/webapps/host-manager/META-INF/context.xml,添加“192.\d+.\d+.\d+”代表可远程访问该服务器的IP地址段,192...*(此处注意正则表达式)

[[email protected] conf]# vim /usr/local/include/tomcat8/webapps/manager/META-INF/context.xml
                <?xml version="1.0" encoding="UTF-8"?>
                <Context antiResourceLocking="false" privileged="true" >
                <Valve className="org.apache.catalina.valves.RemoteAddrValve"
                             allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1|192\.\d+\.\d+\.\d+" />
                </Context>
 
            重新启动tomcat服务

[[email protected] conf]# /usr/local/include/tomcat8/bin/catalina.sh stop
                Using CATALINA_BASE:   /usr/local/include/tomcat8
                Using CATALINA_HOME:   /usr/local/include/tomcat8
                Using CATALINA_TMPDIR: /usr/local/include/tomcat8/temp
                Using JRE_HOME:        /usr/local/include/jdk/
                Using CLASSPATH:       /usr/local/include/tomcat8/bin/bootstrap.jar:/usr/local/include/tomcat8/bin/tomcat-juli.jar
                [[email protected] conf]# /usr/local/include/tomcat8/bin/catalina.sh start
                Using CATALINA_BASE:   /usr/local/include/tomcat8
                Using CATALINA_HOME:   /usr/local/include/tomcat8
                Using CATALINA_TMPDIR: /usr/local/include/tomcat8/temp
                Using JRE_HOME:        /usr/local/include/jdk/
                Using CLASSPATH:       /usr/local/include/tomcat8/bin/bootstrap.jar:/usr/local/include/tomcat8/bin/tomcat-juli.jar
                Tomcat started.

此时可以就可以正常开启tomcat的Manager App、Host Manager、Server Status等页面

4.在Tomcat上部署Jenkins系统
    4.1将下载好的Jenkins的war包放在/data/www/jenkins/文件夹下面

[[email protected] jenkins]# pwd
                    /data/www/jenkins
                    [[email protected] jenkins]# ll
                    total 67064
                    -rwxrwxrwx 1 root root 68669812 Apr 11 21:32 jenkins.war

4.2在/usr/local/include/tomcat8/conf/Catalina/localhost/目录下面新建一个名为jenkins.xml的文件。
           文件内容如下:
                                <Context path="jenkins" docBase="/data/www/jenkins/jenkins.war" />
 
            注意:实际上jenkins的war包直接复制到/usr/local/include/tomcat8/webapps/下,就会自动解压,在webapps目录下面自动生成jenkins目录。而且,在发布war包的应用程式时,最好提前停止Tomcat服务。

原文地址:http://blog.51cto.com/hbgslz/2095688

时间: 2024-10-13 16:04:50

JDK+Tomcat+Jenkins部署的相关文章

MV + JDK + Tomcat + Jenkins 安装

1.MV 百度下载自动安装 2.JDK 适合用 yum安装. a.切换到根目录: cd / b.使用 yum search java | grep -i --color JDK 查看JDK现有的版本 (如下图所示) c.使用 yum install java-1.8.0-openjdk-devel.x86_64命令安装 d.使用vi etc/profile 编辑etc文件下的配置文件 ,添加以下类容 (vi 编辑器如何使用若不会使用需要百度) export JAVA_HOME=/usr/lib/

CentOS6.8 部署Tomcat+jenkins+git+maven 持续集成

CentOS6.8 部署Tomcat+jenkins+git+maven 持续集成 一.环境介绍: 1.操作系统:CentOS 6.8  IP:192.168.1.100 2.JDK版本:jdk1.8.0_101 3.Tomcat版本:tomcat-9.0.0.M21 4.jenkins版本: Jenkins ver. 2.46.3 5.git版本:git version 2.9.4 6.maven版本:3.5.0 二.环境部署 1.下载所需软件包 # mkdir /tmp/soft ; cd

CentOS7.0 部署Tomcat+jenkins+git+maven+ant

此篇献给初学者 一.环境介绍:     1.操作系统:CentOS 7.0  IP:192.168.137.128     2.JDK版本:jdk1.8.0_101     3.Tomcat版本:tomcat-9.0.0.M21     4.jenkins版本: Jenkins ver. 2.46.3     5.git版本:git version 2.9.4     6.maven版本:3.5.0     7.ant版本:version 1.10.1 二.环境部署     1.下载所需软件包

jenkins + maven + svn + tomcat 自动部署

jenkins  是做什么用的,如果不知道请自行google 通俗的说  jenkins 可以帮助我们编译发布代码,比如我们提交到SVN后,要发布运行,就可以用过jenkins进行编译运行 环境(这里主要标注下我的环境): 1: SVN服务器 项目检出地址 https://192.168.1.22/svn/trunk/crm   (centos) 2: maven  私服    http://192.168.1.23:8080   (cnetos) 3: tomcat web server  h

Linux(ubuntu/centos) 部署Java项目 外加安装jdk+tomcat+Mysql

这是我第一次写博文,我希望我写的文本能够帮助到大家,这能让我感到很满足! 本次分享的文章 主要解决 Linux下(ubuntu+centos) 部署Java项目 当然也包括安装jdk+tomcat+mysql 准备环境: 系统环境:

Tomcat安装部署和安全加固优化

1.Tomcat介绍 Tomcat是Apache软件基金会(Apache Software Foundation)的Jakarta 项目中的一个核心项目,由Apache.Sun和其他一些公司及个人共同开发而成. Tomcat服务器是一个免费的开放源代码的Web应用服务器,属于轻量级应用服务器,在中小型系统和并发访问用户不是很多的场合下被普遍使用,是开发和调试JSP程序的首选. Tomcat和Nginx.Apache(httpd).lighttpd等Web服务器一样,具有处理HTML页面的功能,另

禅道、jenkins部署记录

禅道部署1.检查你linux系统的位数(uname -a)2.下载对应位数的禅道包3.通过xftp工具将禅道包拷贝到虚拟机的/opt目录4.tar 对禅道包进行解压5.改配置:vi /opt/zbox/etc/mysql/my.cnf 端口号port 3306-->3307 改两个端口vi /opt/zbox/app/zentao/config/my.php 端口号 3306-->33076.启动禅道cd ./zbox start启动禅道7.在浏览器里面输入http://你自己的虚拟机IP地址

Tomcat+Jenkins+SonarQube+SVN+Maven 集成自动化环境搭建(Windows10环境下)

说在前面的话: 从接到任务到完成共用了7天的时间.正常人用不到这个时间. 此时的功能表现是: 登录本地JenKins对项目进行构建,能够自动从SVN读取最新代码并按照Maven项目构建,构建完成能够自动使用SonarQube分析代码质量,并将构建的War包部署到指定容器中. 版权声明:此博客纯手打,个人创作,转载请注明出处 导图: 环境准备:MySQL5.7. Tomcat7.0.93.Tomcat8.5.30.JenKins2.160.SonarQube7.6+Sonar Scanner3.3

tomcat的部署及session绑定反代

Tomcat是由Apache软件基金会下属的Jakarta项目开发的一个Servlet容器,按照 Sun Microsystems提供的技术规范,实现了对Servlet和JavaServer Page(JSP) 的支持,并提供了作为Web服务器的一些特有功能,如Tomcat管理和控制平台. 安全局管理和Tomcat阀等.由于Tomcat本身也内含了一个HTTP服务器,它也可 以被视作一个单独的Web服务器.但是,不能将Tomcat和Apache Web服务器混 淆,Apache Web Serv