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;
        }
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

benboerdong

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

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

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

打赏作者

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

抵扣说明:

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

余额充值