nginx+tomcat+java部署總結

昨天部署了一下nginx+tomcat+java出現了很多問題,以下爲整理總結。

使用了兩種部署方式,一種是源碼部署,一種是war部署。

java源碼部署總結:
環境:nginx+tomcat
部署方式:源碼部署
源碼目錄
  /chroot2/test/schedule 目錄下面就是所有源碼了
tomcat
  位置: /usr/local/tomcat/apache-tomcat-scheduleweb-test
  主要配置文件server.xml
  <Host name="localhost" appBase="/chroot2/test/schedule" deployOnStartup ="false" autoDeploy="false" unpackWARs="true">
         <Context path="/schedule"  docBase="."/>
         <Valve   className="org.apache.catalina.valves.AccessLogValve"   
                 directory="logs"     prefix="schedule-web-test.cn-access_log."   suffix=".log"   
                 pattern="common"   resolveHosts="false"/>
     </Host>
   主要注意: <Context path="/schedule"  docBase="."/>的配置
nginx配置
  upstream配置:
  upstream tomcat_schedule_web_test{
      server localhost:8291 weight=10;
  }

  server配置:
        server
        {
                listen       80;
                server_name test.schedule.toys178.com;
                index index.jsp index.htm index.php;
        root /chroot2/test;

                fastcgi_connect_timeout 600;
                fastcgi_send_timeout 600;
                fastcgi_read_timeout 600;
                 
                                        
                location /schedule {     
                      proxy_pass http://tomcat_schedule_web_test;
                }

                location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|apk|tar.gz)$
                {
                                expires      30d;
                }

                location ~ .*\.(js|css)?$
                {
                                expires      12h;
                }
                access_log  /chroot/wwwlogs/tomcat_schedule_web_test-access.log  access;
        }

部署方式:war包部署
war包目錄
  /chroot2/test/schedule 目錄下面放的是war包,如:ScheduleManage.war
tomcat
  位置: /usr/local/tomcat/apache-tomcat-scheduleweb-test
  主要配置文件server.xml
  <Host name="localhost" appBase="/chroot2/test/schedule" deployOnStartup ="false" autoDeploy="false" unpackWARs="true">
    <Context path="/schedule"  docBase="ScheduleManage.war"/>
       <Valve   className="org.apache.catalina.valves.AccessLogValve"   
              directory="logs"     prefix="schedule-web-test.cn-access_log."   suffix=".log"   
                 pattern="common"   resolveHosts="false"/>
   </Host>
   主要注意: <Context path="/schedule"  docBase="ScheduleManage.war"/>的配置
nginx配置
  upstream配置:
  upstream tomcat_schedule_web_test{
      server localhost:8291 weight=10;
  }

  server配置:
  server
  {
    listen       80;
    server_name test.schedule.toys178.com;
    index index.jsp index.htm index.html;
    root /chroot2/test;
    location /schedule {     
          proxy_pass http://tomcat_schedule_web_test;
    }
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|apk|tar.gz)$
    {
          expires      30d;
    }
    location ~ .*\.(js|css)?$
    {
          expires      12h;
    }
    access_log  /chroot/wwwlogs/tomcat_schedule_web_test-access.log  access;
  }

歡迎關注我的博客園https://www.cnblogs.com/xiangxiaodong/p/4080546.html

http://blog.sina.com.cn/s/blog_1a4dea9270102yg1t.htm

http://blog.sina.cn/dpool/blog/s/blog_1a4dea9270102yg1t.htm

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章