[root@tpwb local]# tar -zxvf apache-tomcat-
# mv apache-tomcat-
在/etc/profile文件中加入:
export TOMCAT_HOME=/opt/apache-tomcat-
使之生效:
# source /etc/profile
//设置之后,凡有登录有页面都会先弹出一个对话框
//建议不动这个文件
$TOMCAT_HOME\webapps\Root\WEB-INF\web.xml
(1)在<web-app>和</web-app>之间加入
<security-constraint>
<web-resource-collection>
<web-resource-name>Entire Application</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<!-- NOTE: This role is not present in the default users file -->
<role-name>manager</role-name>
</auth-constraint>
</security-constraint>
<!-- Define the Login Configuration for this Application -->
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>TEST ACCESS CONTROL</realm-name>
</login-config>
//如果存在就不用加了,注意下面的东东
(2)然后在$TOMCAT_HOME/conf/tomcat-users.xml加入(有颜色部分)
<!--[if !supportLineBreakNewLine]-->
<!--[endif]-->
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="tomcat"/>
<role rolename="role1"/>
<role rolename="manager"/>
<role rolename="admin"/>
<user username="tomcat" password="tomcat" roles="tomcat"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
<user username="role1" password="tomcat" roles="role1"/>
<user username="admin" password="111111" roles="admin,manager"/>
</tomcat-users>
roles的名字和web.xml中的相对应
(3)修改端口号
把8080端口改为80。($TOMCAT_HOME /conf/server.xml)
(4)启动服务
# cd /opt/apache-tomcat-
# ./startup.sh
Using CATALINA_BASE: /opt/apache-tomcat-
Using CATALINA_HOME: /opt/apache-tomcat-
Using CATALINA_TMPDIR: /opt/apache-tomcat-
Using JRE_HOME: /usr/j***a/jdk
(5)在浏览器中输入:http://+IP地址,如果看到了tomcat欢迎页面,说明你的tomcat服务器安装成功。
编辑/etc/rc.d/rc.local 增加内容:
export JDK_HOME=/usr/j***a/jdk
export J***A_HOME=/usr/j***a/jdk1.5.0_13
/opt/apache-tomcat-
这样在系统重启后就可以自动启动Tomcat
注:此并没有安装admin,要重新去下载
欢迎光临 栖息谷-管理人的网上家园 (https://bbs.21manager.com.cn/) | Powered by Discuz! X3.2 |