1、下载对应的Tomcat服务器包
Apache Tomcat官网下载: http://tomcat.apache.org/download-70.cgi
比如我们使用的是 apache-tomcat-7.0.82.tar.gz 下载地址:http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-7/v7.0.82/bin/apache-tomcat-7.0.82.tar.gz
2、上传至Linux服务器并解压出来
上传成功后使用 tar -xzvf apache-tomcat-7.0.82.tar.gz 命令进行解压
drwxr-xr-x 9 root root 4096 Nov 15 16:37 apache-tomcat-7.0.82 -rw-r--r-- 1 root root 8997403 Nov 15 16:25 apache-tomcat-7.0.82.tar.gz
3、上传war项目包
解压完成后进入Tomcat的webapps目录下并上传对应的war项目包
[root@iZj6cgy98yqy7fow7dq2lnZ tomcat]# cd apache-tomcat-7.0./webapps/ [root@iZj6cgy98yqy7fow7dq2lnZ webapps]# ll total drwxr-xr-x root root Nov : docs drwxr-xr-x root root Nov : examples drwxr-xr-x root root Nov : host-manager drwxr-xr-x root root Nov : manager drwxr-xr-x root root Nov : ROOT drwxr-xr-x root root Nov : yun-video -rw-r--r-- root root Nov : yun-video.war [root@iZj6cgy98yqy7fow7dq2lnZ webapps]#
4、修改Tomcat相关server配置文件
[root@iZj6cgy98yqy7fow7dq2lnZ webapps]# vim ../conf/server.xml
修改Tomcat启动端口(默认8080):
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />这里的port可以修改为别的服务端口,也就是Tomcat的启动端口。
修改Tomcat根项目启动
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"> 在这一行配置目录下添加 <Context docBase="${catalina.home}/webapps/yun-video" path="" sessionCookieName="yun-video" />
配置详情:<Context docBase="${catalina.home}/webapps/需要启动的根项目war包名,同等于war解压后的文件夹名" path="" sessionCookieName="session会话共享的识别名" />
添加后的配置:
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"> <Context docBase="${catalina.home}/webapps/yun-video" path="" sessionCookieName="yun-video" /> <!-- SingleSignOn valve, share authentication between web applications Documentation at: /docs/config/valve.html --> <!-- <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> --> <!-- Access log processes all example. Documentation at: /docs/config/valve.html Note: The pattern used is equivalent to using pattern="common" --> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> </Host>
5、启动Tomcat
脚本在bin目录下。
[root@iZj6cgy98yqy7fow7dq2lnZ bin]# sh startup.sh
6、停止tomcat
[root@iZj6cgy98yqy7fow7dq2lnZ bin]# sh shutdown.sh