- nginx 安装

19 阅读1分钟

介绍

高性能 web 服务器、开源免费、服务于静态服务、负载均衡、反向代理;

下载

地址:nginx.org/en/download…; 解压至C/D盘并目录下终端执行。

版本

.\nginx -v

启动

start nginx
\nginx.exe

查看任务进程是否存在

tasklist /fi "imagename eq nginx.exe"

在这里插入图片描述


日志


在这里插入图片描述


修改配置文件

进入解压缩目录,直接文件夹点击进去即可; 或

.\conf\nginx.conf 

在这里插入图片描述


CPU 核心数

worker_processes 2;

代理
        #location / {
            #root   html;
            #index  index.html index.htm;
        #}
        location / {
            proxy_pass   http://localhost:8001;
        }
        location /api/ {
            proxy_pass   http://localhost:8000;
            proxy_set_header Host $host; # 代理 host 地址不一样 需要传入
        }

测试配置文件

修改完成后保存,使用以下命令检查一下配置文件是否正确,后面是 nginx.conf 文件的路径,successful就说明正确。

.\nginx -t

重启

打开浏览器访问刚才的域名及端口 http://localhost:8800,出现欢迎页就说明部署成功了

.\nginx -s reload

停止

.\nginx.exe -s quit
.\nginx.exe -s stop