windowsNginx简单使用
作者:admin 来源: 2024/12/23 21:49:25

一、下载nginx

    从网站下载nginx:https://nginx.org/en/download.html

二、编写配置文件

    编辑conf文件夹中的nginx.conf文件。


        location / {
            root   M:\vue\Bproject\project-v2\dist;
            try_files $uri $uri/ @router;#解决404问题
            index  index.html index.htm;    
            error_page 405 =200  $uri;#解决post接口报405问题      
        }
        location @router
        {
            rewrite ^.*$ /index.html last;
        }

        #解决访问后台接口返回html页面的问题
        location ^~ /api/ {
            proxy_pass http://192.168.8.111:80/;
        }




三、检查配置文件合法性

    在nginx.exe所在目录打开控制台,输入:nginx -t -c C:\Users\Administrator\Downloads\nginx-1.20.2\conf\nginx.conf

    显示successful则表示配置文件OK。

    

    注意:nginx.conf文件另存为ANSI编码,否则任何修改都将不成功。

    

四、启动nginx

    start nginx

称      呼:
联系方式:
您的评论:
技术支持:l.w.dong@qq.com www.luweidong.cn
广州市   wx:lwdred
Copyright © 2014 三味书屋 All Rights Reserved
技术支持:l.w.dong@qq.com  sitemap xml  sitemap html

粤公网安备44010602011869号

粤ICP备13031080号-1