zoukankan      html  css  js  c++  java
  • Jenkins 在 Tomcat 运行访问路径设置

    问题

    最近用 Tomcat 搭建了个 Jenkins ,但是访问的时候需要端口加 /jenkins/ 才能进行访问。我们是直接将 Jenkins.war 包放在 webapps下的。 我们想直接通过不加路径进行访问。

    解决办法

    思路一

    Host 里面进行配置 path ,经过测试,发现是不行的。

    
    <Host name="localhost"  appBase="webapps" path="/jenkins"
                unpackWARs="true" autoDeploy="true">
    </Host>            
    

    思路二(可用)

    新建一个 jenkins 目录在 ./webapps/./webapps/jenkins . 然后将 jenkins.war 解压,然后将压缩包里所有内容放在 ./webapps/jenkins/ 下, 然后在 ./conf/server.xmlHost
    增加一个 Context 配置. 假设路径为 /opt/apache-tomcat-8.5.47/webapps/jenkins,那么配置为

    <Host name="localhost"  appBase="webapps" path="/"
                unpackWARs="true" autoDeploy="true">
            <!-- 新增-->    
            <Context docBase="/opt/apache-tomcat-8.5.47/webapps/jenkins" path="/"    reloadable="true"/>
            <!-- SingleSignOn valve, share authentication between web applications
                 Documentation at: /docs/config/valve.html -->
            <!--
            <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
            -->
    
            <!-- Access log processes all example.
                 Documentation at: /docs/config/valve.html
                 Note: The pattern used is equivalent to using pattern="common" -->
            <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
                   prefix="localhost_access_log" suffix=".txt"
                   pattern="%h %l %u %t &quot;%r&quot; %s %b" />
    
          </Host>
    
    

    然后启动 Jenkins 即可。

    思路三(可用)

    将 jenkins.war 解压,然后将压缩包里所有内容放在 ./webapps/ROOT/ 下,然后启动 jenkins.

    [root@localhost webapps]# pwd
    /opt/apache-tomcat-8.5.47/webapps
    [root@localhost webapps]# ls -l ./ROOT/
    total 2428
    drwxr-x---  3 root root      36 Nov 10 18:22 bootstrap
    -rw-r-----  1 root root    1946 Feb  7  2019 ColorFormatter.class
    drwxr-x---  5 root root     265 Nov 10 18:22 css
    -rw-r-----  1 root root    1544 Oct 28 13:22 dc-license.txt
    drwxr-x---  2 root root      30 Nov 10 18:22 executable
    -rw-r-----  1 root root   17542 Oct 28 13:22 favicon.ico
    drwxr-x--- 12 root root     180 Nov 10 18:22 help
    drwxr-x---  6 root root    4096 Nov 10 18:22 images
    -rw-r-----  1 root root    1674 Feb  7  2019 JNLPMain.class
    drwxr-x---  2 root root     250 Nov 10 18:22 jsbundles
    -rw-r-----  1 root root     862 Feb  7  2019 LogFileOutputStream$1.class
    -rw-r-----  1 root root     636 Feb  7  2019 LogFileOutputStream$2.class
    -rw-r-----  1 root root    2240 Feb  7  2019 LogFileOutputStream.class
    -rw-r-----  1 root root   20730 Feb  7  2019 Main.class
    -rw-r-----  1 root root    1048 Feb  7  2019 MainDialog$1$1.class
    -rw-r-----  1 root root    1067 Feb  7  2019 MainDialog$1.class
    -rw-r-----  1 root root    2633 Feb  7  2019 MainDialog.class
    -rw-r-----  1 root root     512 Feb  7  2019 Main$FileAndDescription.class
    drwxr-x---  3 root root      94 Nov 10 18:22 META-INF
    -rw-r-----  1 root root      71 Oct 28 13:22 robots.txt
    drwxr-x---  3 root root     218 Nov 10 18:22 scripts
    drwxr-x---  7 root root     275 Nov 10 18:22 WEB-INF
    -rw-r-----  1 root root 2390099 May 12 15:50 winstone.jar
    
    

    反思

    1. 经过这个测试,我发现了一个点,当我们 在 Root 目录有内容的时候,我们没有配置 Context 的时候,我们是取 Root 里面的内容的,当我们配置了的 Context 的内容的时候,访问 ip:端口(默认访问),就是我们 Context 里面 docBase 配置的路径。
    2. webapps 下的默认访问是 ROOT,其他在 webapps下的 目录都是需要加路径的(也就是目录名),当我们指定了也就是 Context 里面 docBase 配置的路径,这个时候才不需要加路径。
  • 相关阅读:
    WCF系列之双工通信 牧羊人
    WCF系列之承载(IISHTTP) 牧羊人
    在Ubuntu 10.10下安装JDK配置Eclipse及Tomcat【转载 + 订正】
    gconfeditor简介【转载】
    Ubuntu10.10(linux) 安装jdk1.6及环境变量的设置【转载】
    ubuntu下txt文件中文显示乱码的方法【转载】
    程序员的编辑器——VIM【转载】
    xx is not in the sudoers file 问题解决【转载】
    win7下配置PHP+apache+mysql【转载 + 补充】
    ubuntu忘记密码,忘记root密码的解决方法!【转载】
  • 原文地址:https://www.cnblogs.com/operationhome/p/11831286.html
Copyright © 2011-2022 走看看