• Nginx安装、使用


    一、Linux安装Nginx

    1、安装依赖

    • yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel

    2、下载解压

    • cd /usr/local
    • mkdir nginx
    • cd nginx
    • wget http://nginx.org/download/nginx-1.23.2.tar.gz
    • tar -xvf nginx-1.23.2.tar.gz

    3、安装

    • cd /usr/local/nginx/nginx-1.23.2
      //执行命令 安装ssl证书 添加依赖模块
    • ./configure --with-http_stub_status_module --with-http_ssl_module
    • make
    • make install

    4、改配置、起服务

    • vi /conf/nginx.conf 参看配置
    • ./nginx …/conf/nginx.conf

    5、开放端口:

    • firewall-cmd --zone=public --add-port=8880/tcp --permanent
      *firewall-cmd --reload
    防火墙
    • 开启防火墙 systemctl start firewalld
    • 防火墙装状态 systemctl status firewalld
    • 关闭防火墙 systemctl stop firewalld
    • 关闭端口 firewall-cmd --zone=public --remove-port=25/tcp --permanent

    Windows安装Nginx

    Nginx使用

    Linux命令

    • nginx
    • nginx -s reload

    nginx配置

    
    #user  nobody;
    worker_processes  1;
    
    #error_log  logs/error.log;
    #error_log  logs/error.log  notice;
    #error_log  logs/error.log  info;
    
    #pid        logs/nginx.pid;
    
    
    events {
        worker_connections  1024;
    }
    
    
    http {
        include       mime.types;
        default_type  application/octet-stream;
        sendfile        on;
        #tcp_nopush     on;
        #keepalive_timeout  0;
        keepalive_timeout  65;
        #gzip  on;
       upstream ecif {
            server 192.168.56.10:8078 weight=1;
            server 192.168.56.10:8079 weight=1;
            }
        server {
            listen       8880;
            server_name  localhost;
            location /api/ {
                proxy_pass http://ecif/api/;
            }
             location ~ .*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|js|css)$ {
                # 可以是本机目录页可以是其他服务器,proxy_pass
                proxy_pass http://ecif;
            }
        }
    }
    
    
    • 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
  • 相关阅读:
    Web自动化css选择器定位法实现
    Python开源项目周排行 2023年第32周
    B模块windows渗透
    【云原生之Docker实战】使用docker部署Jellyfin个人影音服务器
    SPI通信
    Elasticsearch(二)
    docker harbor 私有仓库
    【软件测试】作为测试人,因工作与开发吵了一架碰撞,该咋办......
    Unity3D 与 安卓交互
    应用开发类API推荐
  • 原文地址:https://blog.csdn.net/weixin_39559282/article/details/127926139