nginx + tomcat releases web application

Reference blog post https://www.cnblogs.com/tuojunjie/p/6229783.html

1. Because nginx has been followed, skip installation and Linux is the Ali server for rent

2. File preparation, upload the war package to the specified directory through flashFXP or other software

3. Install tomcat

cp -r apache-tomcat-8.5.23.tar.gz /mnt/upload/ryqp/

rm -rf apache-tomcat-8.5.23

tar xzf apache-tomcat-8.5.23.tar.gz 
4. Use nginx proxy

#ryqp服务
    upstream ryqp_server{
        server localhost:8089;
    }


     #ryqp 虚拟站点
     server {
        listen       80;
        server_name  test.ryqp.com;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
           # root   html;
           # index  index.html index.htm;
           #proxy_pass http://sdk_server/muzhike/;
           #rewrite ^/muzhike/(.*)$ /$1 last;
           proxy_pass http://ryqp_server/ryqp/;
           rewrite ^/ryqp/(.*)$ /$1 last;
           proxy_set_header        X-Real-IP       $remote_addr;
           proxy_set_header        Host            $host;
           proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_pass_request_headers              on;

        }

        #location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
        #   proxy_pass http://ryqp_server/ryqp;
        #}

        #location ~ .*\.(js|css)?$ {
        #    proxy_pass http://ryqp_server/ryqp;
        #}

        error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }
The configuration is a bit simple, forgive me, you can refer to the works of other great gods

Restart nginx: in the sbin directory

[root@iZ94776685oZ conf]# cd ../sbin/
[root@iZ94776685oZ sbin]# ./nginx -s reload

After starting, verify

5. Configure tomcat: service.xml

<Connector port="8089" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
If it is a web, the default is 8080, I have already been occupied
<Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
	<Context path="/ryqp" docBase="/mnt/upload/ryqp/ha-ryqp-interface-1.0.0-SNAPSHOT.war" reloadable="true"></Context>
        <!-- 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>

Add the context tag and specify the path of the war package, so there is no need to put it under webapps

Go to the tomcat bin directory and use the script command ./startup.sh

You can view the log log, view the start

 You can verify by accessing the web project path

Published 64 original articles · Like9 · Visit 110,000+

Guess you like

Origin blog.csdn.net/eadela/article/details/78928059