Mac 下安裝tomcat


一. 下載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/

  啟動服務命令:

  sudo sh startup.sh

  啟動成功,會出現如下結果:

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.

  如果出現如上結果,說明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開發的應該很熟悉,這里不再討論

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM