唉,心情不好,就这样吧。
如题,今天安装了tomcat7,系统是 13.04。其实几天前就安装好了。但是今天又删了,重新安装,结果遇到了不少问题。简单记录一下吧。其实可以从源中直接安装,这里安装的版本是7,搜索命令,把里面列举出来的都一并装上吧,比如 什么 example,docs,admin 这里的。
sudo apt-cache search tomcat7
sudo apt-get install tomcat7
sudo apt-get install tomcat7-admin
安装完之后,主要的文件分布在这几个目录下面。
/usr/share/tomcat7 最主要的目录,比如tomcat7 的startup.sh 和 shutdown.sh 都在bin里面,这是我们最终要整合过来的目录。
/etc/tomcat7/ 这里主要是一些配置文件。
/var/lib/tomcat7/ 这里也有不少,webapp,work,conf,什么的
如果安装成功了,浏览器访问localhost:8080应该可以看到这个页面。
然后看一下你的 /usr/share/tomcat7/ 有没有 common,work, 等目录,如果有就是正常的,如果没有,那么这些缺少的目录一定在 /var/lib/tomcat7 中,你只需要把他们软链接过来就行。我懒得自己敲命令,写了个脚本来做,没有啦,其实是想练习下python.:)
#!/bin/python
import os
import json
str1 = os.listdir('/var/lib/tomcat7/')
str2 = '/usr/share/tomcat7/'
#str11 = json.dumps(str1)
#str22 = json.dumps(str2)
for i in str1:
command = 'sudo ln -s '+'/var/lib/tomcat7/'+i+' '+str2+i
os.system(command)
print "Done"
只要是和目录相关的问题,做完这个脚本,应该就没有问题了,对应的目录应该是这样的。
启动 和 关闭 tomcat7 的方法是
sudo /usr/share/tomcat7/startup.sh
sduo /usr/share/tomcat7/shutdown.sh
当然,可以写脚本或者做软链接都可以,系统是你的,怎么高兴怎么整。
下面的问题是 使用 tomcat-admin.当然前提是你安装了。
其实要做的就是修改一个配置文件。
/usr/share/tomcat7/conf/tomcat7-user.xml,在里面编辑内容,不然你无法访问 tomcat7-admin。其实也很简单,第一次访问的时候,会弹出一个 dialog,你不知道怎么输,然后它会提示你,修改你的tomcat7-user.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="manager-gui"/>
<role rolename="admin-gui"/>
<user username="yourname" password="yourpaswd" roles="tomcat,manager-gui,admin-gui"/>
</tomcat-users>
进入后台。
qi
好吧,就这样吧,早点休息。