一. 下載tomcat
首先要到tomcat官網去下載安裝包,官網下載地址如下:http://tomcat.apache.org/download-70.cgi , 注意請下載飛windows版本。和windows作業系統不一樣,這個裡面沒有令人厭煩的註冊表。
將壓縮包解壓到任意一個目錄,我這裡是存放到/ProgramFile/tomcat 目錄下面
二. 修改授權
tomcat中的幾個運行服務程式都是以*.sh結尾的,在運行之前需要授權。開啟終端輸入如下命令:
輸入如下命令:
sudo chmod 755 /ProgramFile/tomcat/bin/*.sh
斷行符號出現要輸入密碼:請輸入本機賬戶密碼
三. 啟動tomcat服務
先使用 cd 命令進入tomcat的bin目錄,命令如下:
cd /ProgramFile/tomcat/bin/
啟動服務命令:
啟動成功,會出現如下結果:
Using CATALINA_BASE: /ProgramFile/tomcatUsing CATALINA_HOME: /ProgramFile/tomcatUsing CATALINA_TMPDIR: /ProgramFile/tomcat/tempUsing JRE_HOME: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/HomeUsing CLASSPATH: /ProgramFile/tomcat/bin/bootstrap.jar:/ProgramFile/tomcat/bin/tomcat-juli.jarTomcat started.
如果出現如上結果,說明tomcat啟動成功
四. tomcat 相關配置的修改
開啟tomcat中的 /tomcat/conf/tomcat-users.xml 檔案。
<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> 都是被注釋的,這裡添加如下:
<role rolename="manager"/><user username="tomcat" password="root" roles="manager"/>
更多配置修改,可以查看tomcat的相關資料
這個時候輸入 http://localhost:8080/ 應該就可以訪問了,做java web開發的應該很熟悉,這裡不再討論