找到自己的nginx.conf文件
vim nginx.conf
如下图
找到此处并修改配置
这里写上自己的文件路径
location / {
root /home/server/dist;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}location /two{
alias /home/server/dist2;
index index.html index.htm;
try_files $uri $uri/ /supplier/index.html;
找到项目里的router里的index.js
base表示基础路径,这里可以自己定义,要与nginx.conf文件里location /two这里的two相对应
找到vue.config.js
这里的publicPath也要nginx.conf文件里location /two这里的two相对应
然后打包项目生成dist文件
npm run build
启动nginx就可以访问项目地址了
以上就是解决nginx部署第二个项目的全过程,希望对你有所帮助。