您的位置:首页 > 运维架构 > Tomcat

安装tomcat

2015-12-07 10:48 597 查看
1.下载

wget http://ftp.wayne.edu/apache/tomcat/tomcat-8/v8.0.29/bin/apache-tomcat-8.0.29.zip unzip apache-tomcat-8.0.29.zip
cp -R apache-tomcat-8.0.29 /usr/local/tomcat

2。配置:添加配置

cd /usr/local/tomcat/conf/
vim  tomcat-users.xml


<tomcat-users xmlns="http://tomcat.apache.org/xml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
version="1.0">
<!--
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="tomcat"/>
<user username="tomcat" password="tomcat" roles="tomcat"/>

</tomcat-users>


添加用户
useradd tomcat


修改默认端口:
vim server.xml 

找到8080 改为9090

2.启动

cd/usr/local/tomcat/startup.sh

关闭

cd/usr/local/tomcat/shutdown.sh

访问:10.10.10.252:9090  欧耶~



3 配置:

如果想要配置其他的路径,可以这样:

cd /usr/local/tomcat/conf

vim server.xml 

在页面的底部添加:

<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
<Context path="/" docBase="/www/web/java"></Context>
</Host>
</Engine>
</Service>
</Server>

添加的部分为 : <Context path="/" docBase="/www/web/java"></Context>

也就是为:/www/web/java 

然后这里添加文件/www/web/java/index.html

然后访问:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: