一、切换到nginx的配置文件路径下:cd /usr/local/nginx/conf
二、编辑nginx的配置文件:vim nginx.conf
三、修改或添加location代码块,如下
location /project1{
alias /usr/local/nginx/dist#静态资源路径
index index.html index.htm;
}
location /project2{
alias /usr/local/nginx/dist#静态资源路径
index index.html index.htm;
}
四、浏览器访问方式:ip+端口+/project1或2
当浏览器发起请求访问location后的路径时,nginx将请求转发到location代码块内静态资源路径发起真实的访问。