时间:2022-12-10来源:www.pcxitongcheng.com作者:电脑系统城
去官网下载nginx压缩包,解压到电脑合适位置,我这放在D盘,目录是D:\nginx-1.21.6,
在这个路径,直接输入cmd,打开命令行,启动命令:
nginx.exe
或者
start nginx
关闭命令
taskkill /f /t /im nginx.exe
改了配置文件,不需要先关闭再启动,直接重启,重启命令
nginx -s reload
有时候会根据需要,区分不用的vue项目,这样要加一个前缀,不加前缀,访问是http://localhost:8080/
,加一个前缀,cancer,访问路径就是http://localhost:8080/cancer
这个路径,在router/index.js修改配置,增加一个base
1 2 3 4 5 6 7 8 |
const router = new VueRouter({ routes: routes.concat(asyncRouterMap), base: window.publicPath ? window.publicPath + "/" : "" , mode: process.env.NODE_ENV === "production" || process.env.NODE_ENV === "test" ? "history" : "hash" , }); |
window.publicPath就是需要的前缀,window.publicPath = “/cancer”;
然后npm run build打包,把打包后的文件,在nignx路径下html文件夹下,新建一个文件夹,cancer,把包里的内容放进去
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
server { #前端启动端口监听 listen 8780; #本机ip,也可以是域名 server_name 192.168.2.87; location / { root html; index index.html index.htm; } location /cancer { alias html/cancer; index index.html index.htm; try_files $uri $uri/ /cancer/index.html; } |
2022-12-15
Valheim服务器 Mod修改安装教程2022-12-08
利用VSCode进行远程Linux服务器、容器开发,达到ide开发项目的效果(最新推荐)2022-12-08
基于Nginx搭建WebDAV服务的详细过程Nginx (engine x) 是一个高性能的HTTP和反向代理web服务器,同时也提供了IMAP/POP3/SMTP服务,这篇文章主要介绍了nginx配置访问本地静态资源,需要的朋友可以参考下...
2022-12-08