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

<Connector port="8089" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
如果是一个web,默认8080就可以了,我这边已经被占用了
<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>

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

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

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

 访问web项目路径即可验证

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

eadela

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值