• Nginx


    服务器概述

    1、Nginx

    文章参考
    nginx学习,看这一篇就够了:下载、安装。使用:正向代理、反向代理、负载均衡。常用命令和配置文件,很全_java冯坚持的博客-CSDN博客
    点击

    安装和运行

    • Linux
      切换到nginx目录下
      cd /usr/local/nginx
    nginx  #部署运行nginx
    
    ps -ef | grep nginx # 查看nginx运行情况
    
    
    • 1
    • 2
    • 3
    • 4

    在这里插入图片描述

    • Windows

    cd nginx目录

    start nginx
    
    • 1

    Nginx目录结构

    nhinx目录结构

    Nginx配置

    配置参考文章

    conf目录下的Nginx.conf

    worker_processes  1;
    events {
        worker_connections  1024;
    }
    http {
        include       mime.types;
        default_type  application/json;
        sendfile        on;
        keepalive_timeout  65;
        server {
            listen       8080;
            //端口号
            server_name  localhost;
            # 指定前端项目所在的位置
            location / {
                root   html/hmdp;
                index  index.html index.htm;
            }
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
            location /api {  
                default_type  application/json;
                #internal;  
                keepalive_timeout   30s;  
                keepalive_requests  1000;  
                #支持keep-alive  
                proxy_http_version 1.1;  
                rewrite /api(/.*) $1 break;  
                proxy_pass_request_headers on;
                #more_clear_input_headers Accept-Encoding;  
                proxy_next_upstream error timeout;  
                proxy_pass http://127.0.0.1:8081;
                #proxy_pass http://backend;
            }
        }
        upstream backend {
            server 127.0.0.1:8081 max_fails=5 fail_timeout=10s weight=1;
            #server 127.0.0.1:8082 max_fails=5 fail_timeout=10s weight=1;
        }  
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43

    2、Tomcat

    文章参考

    Tomcat看这一篇就够了

    目录结构

    D:\1_development\tomcat\apache-tomcat-8.5.31
    在这里插入图片描述

    在windowsAnd LINUX部署tomcat

    安装目录下的bin目录下的startup.bat

    • Linux

    cd tomcat bin目录下

    sh startup.sh
    
    • 1

    visit http://192.168.81.133:8080

    Tomcat配置文件

    D:\1_development\tomcat\apache-tomcat-8.5.31\conf*server.xml*

    • 配置端口号
    
    <Server port="8005" shutdown="SHUTDOWN">
      <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
      
      
      <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
      
      <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
      <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
      <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
    
    
      <GlobalNamingResources>
        
        <Resource name="UserDatabase" auth="Container"
                  type="org.apache.catalina.UserDatabase"
                  description="User database that can be updated and saved"
                  factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
                  pathname="conf/tomcat-users.xml" />
      GlobalNamingResources>
    
      
      <Service name="Catalina">
    
      
        <Connector port="8090" protocol="HTTP/1.1"
                   connectionTimeout="20000"
                   redirectPort="8443" />
        
        <Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
                   maxThreads="150" SSLEnabled="true">
            <SSLHostConfig>
                <Certificate certificateKeystoreFile="conf/localhost-rsa.jks"
                             type="RSA" />
            SSLHostConfig>
        Connector>
        -->
        
        
        <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
    
    
        
        <Engine name="Catalina" defaultHost="localhost">
    
         
          <Realm className="org.apache.catalina.realm.LockOutRealm">
            
            <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
                   resourceName="UserDatabase"/>
          Realm>
    
          <Host name="localhost"  appBase="webapps"
                unpackWARs="true" autoDeploy="true">
    
           
            <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
                   prefix="localhost_access_log" suffix=".txt"
                   pattern="%h %l %u %t "%r" %s %b" />
    		
    		<Context docBase="D:\桌面" path="/heihei" />
    
          Host>
        Engine>
      Service>
    Server>
    
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77

    在Linux部署tomcat

    tomcat的端口号和nginx的端口号冲突怎么办

    二者访问端口号都为8080

    查看windows 8080端口占用
    请添加图片描述

    tomcat和nginx反向代理怎么配置

    tomcat怎么运行项目

    01 将项目打包成war包
    02 上传Linux服务器
    03 war包存放到tomcat的webapps目录下
    04 部署tomcat
    05 访问

    https://blog.csdn.net/kking_Ran/article/details/127540331

  • 相关阅读:
    React篇
    IDEA中application.properties文件中文乱码
    机器学习必修课 - 交叉验证 Cross-Validation
    Netty入门——组件(EventLoop)
    LeetCode刷题笔记-749. 隔离病毒-模拟+搜索
    【PAT甲级题解】PAT-2020年冬季考试-甲级
    第五届传智杯-初赛【B组-题解】
    C语言,-1与sizeof()返回值的比较
    redis中springboot的redisTemplate简单的增删查
    分析报告显示,PHP是编程语言主力军,且在电商领域占据“统治地位”
  • 原文地址:https://blog.csdn.net/m0_46179147/article/details/126772064