用tomcat搭建本地web環境

來源:互聯網
上載者:User

標籤:運行   cut   blog   href   dir   targe   webapp   php   rtu   

:http://www.oracle.com/technetwork/java/javase/downloads/index.html。

安裝並設定JAVA_HOME環境變數:

第二步:下載和解壓 Tomcat

:http://tomcat.apache.org/。

解壓之後檔案的樣子

配置tomcat的環境變數

第三步:修改連接埠號碼

.NET 我使用的是 80xx,Php 我使用的是 81xx,Java 我使用的是 82xx。

修改D:\apache-tomcat-8.0.0-RC3\conf\server.xml:

 1   <Service name="Catalina"> 2  3     <!--The connectors can use a shared executor, you can define one or more named thread pools--> 4     <!-- 5     <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" 6         maxThreads="150" minSpareThreads="4"/> 7     --> 8  9 10     <!-- A "Connector" represents an endpoint by which requests are received11          and responses are returned. Documentation at :12          Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)13          Java AJP  Connector: /docs/config/ajp.html14          APR (HTTP/AJP) Connector: /docs/apr.html15          Define a non-SSL HTTP/1.1 Connector on port 808016     -->17     <Connector port="8200" protocol="HTTP/1.1"18                connectionTimeout="20000"19                redirectPort="8443" />
第四步:加入自己的檔案
將你的檔案夾拷貝到tomcat安裝目錄下的webapp檔案夾裡面
比如你的網站檔案夾名稱是asdf,你的ip是172.18.40.111,那麼你就開啟瀏覽器輸入
172.18.40.111:8080/asdf/xxx.jsp即可訪問,如果是本機就直接localhost:8080/asdf/xxx.jsp
第五步:測試 Tomcat

運行:D:\apache-tomcat-8.0.0-RC3\bin\startup.bat或者雙擊D:\apache-tomcat-8.0.0-RC3\bin\startup.bat檔案,如果視窗沒有立即關閉,就代表成功了。

第五步:發布自己的網站

最簡單的發布方式莫過於將網站直接拷貝到:D:\apache-tomcat-8.0.0-RC3\webapps,這裡介紹另外一種方式。

在D:\apache-tomcat-8.0.0-RC3\conf\Catalina\localhost下面建立一個naming.xml檔案,內容如下:

1 <Context docBase="E:\Workspaces\Naming\1\WebRoot" debug="0" privileged="true">2 </Context>

效果:

第六步:管理 Web App

 

 當點擊 Manager App 的時候,會要求輸入使用者名稱和密碼,可以在 D:\apache-tomcat-8.0.0-RC3\conf\tomcat-users.xml 中增加使用者名稱,如下:

1 <?xml version=‘1.0‘ encoding=‘utf-8‘?>2 <tomcat-users>3   <role rolename="manager-gui"/>4   <user username="admin" password="123456" roles="manager-gui"/>5 </tomcat-users>

注意:這是因為 Tomcat 支援 JAAS。

小tips:

如果一台電腦上項裝兩個tomcat,可以按一下步奏操作:

  1. 將tomcat的整個安裝檔案複製放到另一個目錄下;

  2. 電腦-屬性-環境變數裡的 CATALINA_HOME, 複製一個重新命名為CATALINA_HOME2=新路徑;

  3. 將\apache-tomcat-7.0.32-windows-x64\apache-tomcat-7.0.32\bin裡的.bat檔案裡所有的CATALINA_HOME替換為CATALINA_HOME2;

  4. 雙擊starup.bat即可。

 

用tomcat搭建本地web環境

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.