准备工作
mkdir /data/server/nginx/web1/dir{1,2}
echo "nginx web1 dir1" > /data/server/nginx/web1/dir1/index.html
echo "nginx web1 dir2" > /data/server/nginx/web1/dir2/index.html
echo "nginx web1 filea" > /data/server/nginx/web1/afile
tree /data/server/nginx/web1


定制配置文件
/etc/nginx/conf.d/vhost.conf <<-eof
server {
listen 80 default_server;
root /data/server/nginx/web1;
location /dir1/ {
root /data/server/nginx/web1;
}
}
eof

重启服务
systemctl reload nginx

测试
curl localhost

定制配置文件
vim /etc/nginx/conf.d/vhost.conf

重启服务
systemctl reload nginx

测试
curl localhost
curl localhost/web2/
curl localhost/web3/
