Tomcat-MAC下添加Tomcat环境并运行

时间:2021-12-02 10:14:20

MAC下添加Tomcat环境运行

1. 首先,下载tomcat。http://tomcat.apache.org/index.html

2. 然后解压。用终端进入到解压文件夹下的bin目录。 

AlundeMacBook-Pro:bin alun$ pwd

/Users/alun/资料/JAVA/apache-tomcat-8.0.32-Local/bin

3. 这时运行startup.bat文件会报权限不够的错。

AlundeMacBook-Pro:bin alun$ ./startup.sh

-bash: ./startup.sh: Permission denied

  我们这里要赋予权限。下面命令:

sudo chmod 755 /Users/alun/资料/JAVA/apache-tomcat-8.0.32-Local/bin/startup.sh

权限赋给后,我们直接在终端输入./startup.sh就能运行程序了。

AlundeMacBook-Pro:bin alun$ ./shutdown.sh

Using CATALINA_BASE:   /Users/alun/资料/JAVA/apache-tomcat-8.0.32-Local

Using CATALINA_HOME:   /Users/alun/资料/JAVA/apache-tomcat-8.0.32-Local

Using CATALINA_TMPDIR: /Users/alun/资料/JAVA/apache-tomcat-8.0.32-Local/temp

Using JRE_HOME:        /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home

Using CLASSPATH:       /Users/alun/资料/JAVA/apache-tomcat-8.0.32-Local/bin/bootstrap.jar:/Users/alun/资料/JAVA/apache-tomcat-8.0.32-Local/bin/tomcat-juli.jar

AlundeMacBook-Pro:bin alun$ pwd

/Users/alun/资料/JAVA/apache-tomcat-8.0.32-Local/bin

AlundeMacBook-Pro:bin alun$ ./startup.sh

Using CATALINA_BASE:   /Users/alun/资料/JAVA/apache-tomcat-8.0.32-Local

Using CATALINA_HOME:   /Users/alun/资料/JAVA/apache-tomcat-8.0.32-Local

Using CATALINA_TMPDIR: /Users/alun/资料/JAVA/apache-tomcat-8.0.32-Local/temp

Using JRE_HOME:        /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home

Using CLASSPATH:       /Users/alun/资料/JAVA/apache-tomcat-8.0.32-Local/bin/bootstrap.jar:/Users/alun/资料/JAVA/apache-tomcat-8.0.32-Local/bin/tomcat-juli.jar

Tomcat started.

4. 最后浏览器上面输入http://localhost:8080/ 就能访问了。默认是8080端口