window

命令

start nginx // 开机启动,不要使用 ./nginx会丢失光标

./nginx -s reload //重启
./nginx -s stop 停止
./nginx -t 配置是否正确

前端部署

单文件

index.html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    index
</body>
</html>
nginx.conf
worker_processes 1;
events {
    worker_connections 1024;
}

http {
    server {
        listen 80;
        location / {
            root html;
            index index.html index.htm;
        }
    }
}
效果
image.png

image.png

vueCli项目根路径

vue项目配置

image.png

nginx.conf
worker_processes 1;
events {
    worker_connections 1024;
}

http {
    server {
        listen 80;
        location / {
            root html;
            index index.html index.htm;
        }
    }
    server {
        # //不能写80
        listen 81;
        location / {
            root html/app;
            index index.html index.htm;
        }

    }
}

image.png

效果

image.png

vueCli项目子路径

vue项目配置

image.png

nginx.conf
worker_processes 1;
events {
    worker_connections 1024;
}

http {
    server {
        listen 80;

        location /my-app {
            root html/dist;
            index index.html index.htm;
        }
    }
}

image.png

效果

image.png


aaaa
5 声望0 粉丝

« 上一篇
njs
下一篇 »
页面崩溃