一. nginx安装

1. 下载nginx, 选择下载Stable version版本;
2. 安装到本地文件夹,我这里是安装到的E盘,依据个人喜好,不做过多赘述,nginx安装位置

二. 启动nginx

进入到nginx文件夹内,打开终端输入执行命令
1. 启动: start nginx;
2. 重启: ./nginx -s reload;
3. 强制关闭:./nginx -s stop;
4. 丝滑关闭: ./nginx -s quit;

注意:这里如果用 gitbash 的终端执行重启命令就会出现 bash: nginx: command not found 的提示,在网上查了些资料,原因大致是由于 windows 系统执行了 Linux 命令,导致无法通过该命令找到对应的模块,如果用windows自带的终端就可以顺利执行重启命令


gitbash 时:
nginx在gitbash错误提示
windows 时:
windows执行重启命令

三. 启动成功及代理

配置代理
server {
		# 监听的端口
        listen       9595;
        # 访问的服务器地址
        server_name  127.0.0.1;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }
        
        # 项目代理
        location /pc {
            alias F:\\xxxx\xxx;
        }

        # 图片服务器打理
        location /file {
            alias C:\\xxx\Pictures;
        }

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

项目展示:
本地代理成功
代理图片展示:
在这里插入图片描述
至此 windows 系统配置本地服务器及代理配置成功,同理可在服务器配置nginx相关代理.

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐