nginx+tomcat发布web程序

参考博文https://www.cnblogs.com/tuojunjie/p/6229783.html

1、因为nginx已经按照,跳过安装,linux是租的阿里服务器

2、文件准备,通过flashFXP或者其他软件上传war包到指定目录

3、安装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、用nginx代理

#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;
        #}
    }
配置的有点简单,见谅呐,可以参考其他大神的作品

重启nginx:在sbin目录下

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

启动好后,进行验证

5、配置tomcat:service.xml

如果是一个web,默认8080就可以了,我这边已经被占用了

	
        
        

        
        

      

添加context标签,指定war包路径,这样就没必要放到webapps下面了

到tomcat的bin目录下使用脚本命令  ./startup.sh

可以查看log日志,查看启动

 访问web项目路径即可验证

你可能感兴趣的:(nginx+tomcat发布web程序)