Tomcat7的安装与配置
Tomcat的安裝及配置我曾經使用過tomcat,并實現了一個簡單的servlet程序。沒想到再次安裝tomcat的時候用浪費了我大半天的時間。我想有必要做個總結,否則下次不知又要花費我多少時間。
?1、 Tomcat下載
????Tomcat是Apache開源工程的一個項目,因此我們可以去http://tomcat.apache.org/ tomcat官網去下最新版本的tomcat。目前最新的是Tomcat7.02,但是由于tomcat與jdk版本需要匹配(一般情況是jdk1.5對應tomcat5,jdk1.6對應tomcat6),保險起見還是選用用Tomcat6 。網址:http://tomcat.apache.org/download-60.cgi 問題來了,網站上提供了多種版本的tomcat,到底哪一款適合我呢?在網站提供的README文件中給出了各個版本的介紹如下:
apache-tomcat-[version].zip or .tar.gz
Base distribution. These distributions do not include the Windows service wrapper nor the compiled APR/native library for Windows.
apache-tomcat-[version].exe
32-bit/64-bit Windows installer for Tomcat. Please note that while this distribution includes the vast majority of the base distribution, some of the command-line scripts for launching Tomcat are not included. This distribution is intended for those users planning to launch Tomcat through the Windows shortcuts or services.
apache-tomcat-[version]-windows-x86.zip
32-bit Windows specific distribution that includes the Windows service wrapper and the compiled APR/native library for use with 32-bit JVMs on both 32 and 64 bit Windows platforms.
apache-tomcat-[version]-windows-x64.zip
64-bit Windows specific distribution that includes the Windows service wrapper and the compiled APR/native library for use with 64-bit JVMs on x64 Windows platforms.
apache-tomcat-[version]-windows-i64.zip
64-bit Windows specific distribution that includes the Windows service wrapper and the compiled APR/native library for use with 64-bit JVMs on Itanium 64-bit Windows platforms.
apache-tomcat-[version]-deployer.zip or .tar.gz
The standalone Tomcat Web Application Deployer. apache-tomcat-[version]-fulldocs.tar.gz The Tomcat documentation bundle, including complete javadocs.
一般情況我們選擇apache-tomcat-[version]-windows-x86.zip 下載后直接解壓至指定目錄即可(我選擇了C:\tomcat) 。當然我們只關心binary distributions就可以了,至于code版就看你個人學習激情了。
?2、 tomcat 環境配置
????配置Tomcat的環境變量:在“我的電腦”上點右鍵—>“屬性”—>“高級”—> “環境變量(N)”。
1、新建系統變量CATALINA_HOME:C:\Tomcat(注意此后不要加分號)
2、新建系統變量TOMCAT_HOME:C:\Tomcat(好像是為了MyEclipse配置的)
3.在系統變量CLASSPATH的值的后面加入:CATALINA_HOME%\lib;(這個要加分號)
4、在系統變量Path的值的后面加入以下內容:CATALINA_HOME%\bin;f\方便用戶運行tomcat的各種腳本:
5、在系統變量CLASSPATH的值的加入: CATALINA_HOME%\lib\servlet-api.jar;
3、 運行tomcat??直接運行startup.bat
????個人建議用命令提示符程序(cmd.exe)運行C:\Tomcat\bin目錄下的批處理文件(.bat)。如:注意要在當前目錄下運行否則找不到 C:\Tomcat\bin> startup.bat install C:\Tomcat\bin> shutdown.bat install C:\Tomcat\bin> service.bat install 開啟tomcat后可以用瀏覽器訪問http://localhost:8080/ 如果出現tomcat的界面就說明你已經成功安裝tomcat。
4、 tomcat賬戶設置
????如果你選擇的是exe安裝文件,在安裝過程中他會提示你輸入用戶名密碼。
????如果你用的是解壓包形式的,則需要在CATALINA_HOME/conf/tomcat-users.xml文件中。編輯這個文件,可以修改用戶名和密碼,例如添加一個名叫“tomcat”的“manager”角色到該文件中:然后重新啟動Tomcat。 登錄時輸入tomcat,密碼tomcat即可。注意:rolename 只能是manager
5、 win7下tomcat6w.exe無法運行:
????在windows7操作系統下,安裝了tomcat6。雙擊tomcat6w.exe時,提示錯誤“Unable to open the service ‘tomcat6’”。解決方法一:此問題可能是windows 7的安全控制限制所致。在tomcat6w.exe文件上點擊右鍵--屬性--兼容性,勾選“以管理員身份運行此程序”,點擊確定。然后雙擊運行即可;如果還不行見方法二。解決方法二:可能是沒有安裝此項服務。具體安裝方法:打開命令行提示符窗口 => 進入Tomcat安裝目錄==> 進入bin目錄下==> 輸入:service.bat install 即可。如果還是不行,目前就不知道如何解決,還希望知道的大牛們給出本質的解決方案!(可能的原因由于網絡端口獨占不能兩個tomcat同時運行)
6、tomcat.ext 與tomcat6.ext主要區別:
?????tomcat6.exe與tomcat6w.exe這兩個都能啟動tomcat,一個是提供dos界面的啟動方式,一個是可視化的界面啟動方式。但是呢tomcat6w.exe并不是用來啟動tomcat的,而是用來配置tomcat在windows下的系統服務的。兩個不能同時啟動。
7.訪問俄服務器8080端口時,在地址欄一定要輸入"http"的完整形式,否則瀏覽器可能不會使用http協議去訪問該端口。
posted on 2017-05-31 20:16 訣語塵定 閱讀(...) 評論(...) 編輯 收藏轉載于:https://www.cnblogs.com/iihcy/p/6925786.html
總結
以上是生活随笔為你收集整理的Tomcat7的安装与配置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mac 下idea光标问题
- 下一篇: 解题代码 用jquery控制一个按钮当一