最近用 Tomcat
搭建了個 Jenkins
,可是訪問的時候須要端口加 /jenkins/
才能進行訪問。咱們是直接將 Jenkins.war 包放在 webapps
下的。 咱們想直接經過不加路徑進行訪問。css
在 Host
裏面進行配置 path ,通過測試,發現是不行的。html
<Host name="localhost" appBase="webapps" path="/jenkins" unpackWARs="true" autoDeploy="true"> </Host>
新建一個 jenkins 目錄在 ./webapps/
下 ./webapps/jenkins
. 而後將 jenkins.war 解壓,而後將壓縮包裏全部內容放在 ./webapps/jenkins/
下, 而後在 ./conf/server.xml
的 Host
增長一個 Context
配置. 假設路徑爲 /opt/apache-tomcat-8.5.47/webapps/jenkins
,那麼配置爲web
<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 "%r" %s %b" /> </Host>
而後啓動 Jenkins 便可。apache
將 jenkins.war 解壓,而後將壓縮包裏全部內容放在 ./webapps/ROOT/
下,而後啓動 jenkins.bootstrap
[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
ROOT
,其餘在 webapps
下的 目錄都是須要加路徑的(也就是目錄名),當咱們指定了也就是 Context 裏面 docBase 配置的路徑,這個時候纔不須要加路徑。