1.建立一个server模块,从nginx.conf中分离出来,将前端代码,静态资源的文件地址加入到server中

image.png
注意:下面的location不能直接/,会冲突,根据下面root目录填写子目录。 相当于/home/imooc
server{
listen 89;
server_name localhost;
location / {
root html;
index imooc.html index.htm;
}
}
server{
listen 90;
server_name localhost;
location / {
root /home/foodie-shop;
index index.html;
}
<第一种方式>
location /imooc{
root /home;
}
<第二种方式>:[http://192.168.35.132:90/static/img/face1.png](http://192.168.35.132:90/static/img/face1.png)
会将/home/imooc隐藏
location /static{
location /static {
alias /home/imooc;
}
}