Vue发布到Nginx访问IIS后端WebApi
一、把文件夹dist打包后的文件夹移动到Nginx目录
打包命令:pnpm run build
vue本地代理是没用的,要使用nginx
二、修改配置文件nginx.conf
D:\tools\nginx-1.17.8
1、监听端口号
server { listen 8849; server_name localhost;
2、启动目录
location / {
root dist;
index index.html index.htm;
}
3、后端接口,放到location前后都可以
注意符号必须:这两处/必须,和最后的;
location /api/ { proxy_pass http://localhost:8888/; }
localhost同127.0.0.1
三、设置nginx开机自启动
@echo off cd /d D:\tools\nginx-1.17.8 start nginx
nginx目录创建批处理文件 start_nginx.bat
发布到桌面- 快捷方式
复制放到Windows启动目录C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
就可以开机自启动
在nginx目录cmd命令窗口执行
常见nginx命令:
启动 start nginx
快速停止 nginx -s stop
正常停止 nginx -s quit
重启服务: service nginx restart
配置文件修改重装载命令:nginx -s reload
常见错误:
No mapping for the Unicode character exists in the target multi-byte code pa
目标多字节码pa中不存在Unicode字符的映射
即路径存在中文,换个没有中文的安装路径即可
浙公网安备 33010602011771号