首先去下载apache-tomcat的服务包:
地址是:
http://pan.baidu.com/share/link?shareid=357494&uk=974040524
然后:
1.解压将文件加命名为Tomcat,可以把这个文件加移动到根目录/Library中.
2.在Terminal中执行 sudo sh Library/Tomcat/bin/startup.sh,如果遇到提示No such file or directory错误提示, chmod a+x Library/Tomcat/bin/*.sh.
3.再使用browser連到http://localhost:8080, 如果可以看到tomcat的欢迎页就ok。
也可以将你的html5 工程copy到刚才解压的Tomcat目录下
如下:
用自己的 ios app 的 uiwebview 就可以加载这个界面了:
或者用 safari打开也可以访问了:
开启:sudo sh /Library/tomcat/bin/startup.sh
关闭:sudo sh /Library/tomcat/bin/shutdown.sh
注意:有可能遇到下面的问题:
server:bin justinjing$ sudo sh startup.sh
startup.sh: /Users/justinjing/Desktop/apache-tomcat-7.0.37/bin/catalina.sh: /bin/sh: bad interpreter: Operation not permitted
startup.sh: line 62: /Users/justinjing/Desktop/apache-tomcat-7.0.37/bin/catalina.sh: Undefined error: 0
startup.sh: /Users/justinjing/Desktop/apache-tomcat-7.0.37/bin/catalina.sh: /bin/sh: bad interpreter: Operation not permitted
startup.sh: line 62: /Users/justinjing/Desktop/apache-tomcat-7.0.37/bin/catalina.sh: Undefined error: 0
解决方法是:
ls -al@ startup.sh
输出:
-rwxr-xr-x@ 1 justinjing staff 1961 2 13 06:45 startup.sh
com.apple.quarantine 29
-rwxr-xr-x@ 1 justinjing staff 1961 2 13 06:45 startup.sh
com.apple.quarantine 29
然后:
server:bin justinjing$ xattr -d com.apple.quarantine startup.sh
server:bin justinjing$ xattr -d com.apple.quarantine startup.sh
由于startup.sh是执行catalina.sh,所以还要:
server:bin justinjing$ xattr -d com.apple.quarantine catalina.sh
server:bin justinjing$ xattr -d com.apple.quarantine catalina.sh
然后在
server:bin justinjing$ sudo sh startup.sh
Password:
Using CATALINA_BASE: /Users/justinjing/Desktop/apache-tomcat-7.0.37
Using CATALINA_HOME: /Users/justinjing/Desktop/apache-tomcat-7.0.37
Using CATALINA_TMPDIR: /Users/justinjing/Desktop/apache-tomcat-7.0.37/temp
Using JRE_HOME: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Using CLASSPATH: /Users/justinjing/Desktop/apache-tomcat-7.0.37/bin/bootstrap.jar:/Users/justinjing/Desktop/apache-tomcat-7.0.37/bin/tomcat-juli.jar
server:bin justinjing$ sudo sh startup.sh
Password:
Using CATALINA_BASE: /Users/justinjing/Desktop/apache-tomcat-7.0.37
Using CATALINA_HOME: /Users/justinjing/Desktop/apache-tomcat-7.0.37
Using CATALINA_TMPDIR: /Users/justinjing/Desktop/apache-tomcat-7.0.37/temp
Using JRE_HOME: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Using CLASSPATH: /Users/justinjing/Desktop/apache-tomcat-7.0.37/bin/bootstrap.jar:/Users/justinjing/Desktop/apache-tomcat-7.0.37/bin/tomcat-juli.jar
ok了,这样就看到了 tomcat的欢迎界面