ubuntu下配置tomcat的虛擬目錄

來源:互聯網
上載者:User

1、以前在window下配置過tomcat的虛擬目錄,用了myeclipse以後虛擬目錄也就沒用了,因為myeclipse是預設的把項目載入到你tomcat的webapps目錄下的,所以很長時間不配了。在網上查了一些方法,這裡只說常用的一種。

 

1、首先在tomcat/conf/Catalina/localhost目錄下建立一個.xml的檔案,用於配置你tomcat的虛擬目錄,eg:

我的項目名為newXyh所以我建立了一個newXyh.xml,可以通過滑鼠的右鍵建立一個document,不過要修改localhost檔案夾讀寫的許可權:

sudo chmod 777 /opt/tomcat/conf/Catalina/localhost


然後就可以建立了,當然也可以通過命令列建立:

sudo touch newXyh.xml


通過命令:

sudo gedit newXyh.xml


進入到編輯狀態,在newXyh.xml中添加:

<Context path="/newXyh" reloadable="true" docBase="/usr/local/tomcat/newXyh"/> 

其中/usr/local/tomcat/newXyh是我的實際項目目錄。

2、然後開啟tomcat/conf/server.xml檔案:

sudo gedit /opt/tomcat/conf/web.xml


將其中的

<init-param>   <param-name>listings</param-name>   <param-value>false</param-value></init-param>


改為

<init-param>   <param-name>listings</param-name>   <param-value>true</param-value></init-param>

然後重啟tomcat,在瀏覽器上輸入, http://localhost/newXyh,就可以訪問自己的項目了,搞定。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.