一. 下載tomcat
首先要到tomcat官網(wǎng)去下載安裝包,官網(wǎng)下載地址如下:http://tomcat.apache.org/download-70.cgi , 注意請下載飛windows版本。和windows操作系統(tǒng)不一樣,這個里面沒有令人厭煩的注冊表。
將壓縮包解壓到任意一個目錄,我這里是存放到/ProgramFile/tomcat 目錄下面
二. 修改授權(quán)
tomcat中的幾個運行服務(wù)程序都是以*.sh結(jié)尾的,在運行之前需要授權(quán)。打開終端輸入如下命令:
輸入如下命令:
1
|
sudo chmod 755 /ProgramFile/tomcat/bin/ *.sh |
回車出現(xiàn)要輸入密碼:請輸入本機賬戶密碼
三. 啟動tomcat服務(wù)
先使用 cd 命令進入tomcat的bin目錄,命令如下:
1
|
cd /ProgramFile/tomcat/bin/ |
啟動服務(wù)命令:
1
|
sudo sh startup.sh |
啟動成功,會出現(xiàn)如下結(jié)果:
1
2
3
4
5
6
|
Using CATALINA_BASE: /ProgramFile/tomcat Using CATALINA_HOME: /ProgramFile/tomcat Using CATALINA_TMPDIR: /ProgramFile/tomcat/temp Using JRE_HOME: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home Using CLASSPATH: /ProgramFile/tomcat/bin/bootstrap.jar:/ProgramFile/tomcat/bin/tomcat-juli.jar Tomcat started. |
如果出現(xiàn)如上結(jié)果,說明tomcat啟動成功
四. tomcat 相關(guān)配置的修改
打開tomcat中的 /tomcat/conf/tomcat-users.xml 文件。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
< tomcat-users > <!-- NOTE: By default, no user is included in the "manager-gui" role required to operate the "/manager/html" web application. If you wish to use this app, you must define such a user - the username and password are arbitrary. --> <!-- NOTE: The sample user and role entries below are wrapped in a comment and thus are ignored when reading this file. Do not forget to remove <!.. ..> that surrounds them. --> <!-- <role rolename="tomcat"/> <role rolename="role1"/> <user username="tomcat" password="tomcat" roles="tomcat"/> <user username="both" password="tomcat" roles="tomcat,role1"/> <user username="role1" password="tomcat" roles="role1"/> --> < role rolename = "manager" /> < user username = "tomcat" password = "root" roles = "manager" /> </ tomcat-users > |
默認<role> 都是被注釋的,這里添加如下:
1
2
|
< role rolename = "manager" /> < user username = "tomcat" password = "root" roles = "manager" /> |
更多配置修改,可以查看tomcat的相關(guān)資料
這個時候輸入 http://localhost:8080/ 應(yīng)該就可以訪問了,做java web開發(fā)的應(yīng)該很熟悉,這里不再討論