第一次部署javaweb项目到linux(详细)

0.准备工作:

先准备好工具:Xftp 5和Xshell 5

1.先安装tomcat(XShell5里进行):

sa@iZ94sgjyh2cZ:~/service$ tar -vxf apache-tomcat-8.0.43.tar.gz


把解压出来的文件夹改名为air(我个人的项目名):

sa@iZ94sgjyh2cZ:~/service$ mv apache-tomcat-8.0.43 air


现在air文件夹里的结构大概是这样的(在Xftp 5里看):


2.开始部署web项目:

先删除webapps文件加下的所有文件:

sa@iZ94sgjyh2cZ:~/service/air$ rm -rf webapps/*


再在webapps目录上创建一个名为ROOT的目录:

sa@iZ94sgjyh2cZ:~/service/air/webapps$ mkdir ROOT


然后把项目的war包拖进ROOT目录里(用Xftp 5),现在的结构是这样的:



然后解压air.war:

sa@iZ94sgjyh2cZ:~/service/air/webapps/ROOT$ jar -xvf air.war 

解压后大概是这样的:


3.修改tomcat端口配置(如果没有端口占用冲突,可以忽略此步骤):

在conf目录下修改tomcat配置文件:
sa@iZ94sgjyh2cZ:~/service/air/conf$ vim server.xml 


修改web登录端口,先找到这段:

<Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

如果当前有应用占用8080端口, 那么就需要改写port属性,这里我改为9081,即port="9081"


同理,修改服务停止的端口,找到这段:

<Server port="8005" shutdown="SHUTDOWN">

如果当前有应用占用8005端口, 那么就需要改写port属性,这里我改为9516,即port="9516"


另外,如果需要修改项目路径(我的项目里就不做这步一了),找到这段:

<Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">

        <!-- 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 &quot;%r&quot; %s %b" />

</Host>

我们可以在Host标签中添加一个子节点:

<Context path="/air" docBase="/webapps/ROOT" debug="0" privileged="true" reloadable="false"  />


4.启动/停止tomcat服务:

做完以上步骤,现在可以尝试启动tomcat了,先进入tomcat的bin目录,然后执行./startup.sh命令启动tomcat:
sa@iZ94sgjyh2cZ:~/service/air/bin$ ./startup.sh 

我可以顺利启动了:
Using CATALINA_BASE:   /home/sa/service/air
Using CATALINA_HOME:   /home/sa/service/air
Using CATALINA_TMPDIR: /home/sa/service/air/temp
Using JRE_HOME:        /usr/lib/jvm/java-7-openjdk-amd64
Using CLASSPATH:       /home/sa/service/air/bin/bootstrap.jar:/home/sa/service/air/bin/tomcat-juli.jar
Tomcat started.

同理,如果想停止tomcat服务:

sa@iZ94sgjyh2cZ:~/service/air/bin$ ./shutdown.sh 


停止了:
Using CATALINA_BASE:   /home/sa/service/air
Using CATALINA_HOME:   /home/sa/service/air
Using CATALINA_TMPDIR: /home/sa/service/air/temp
Using JRE_HOME:        /usr/lib/jvm/java-7-openjdk-amd64
Using CLASSPATH:       /home/sa/service/air/bin/bootstrap.jar:/home/sa/service/air/bin/tomcat-juli.jar


5.没了


  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值