【Linux】重生之从零开始学习运维之Nginx-root&alias实践

准备工作

复制代码
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/
相关推荐
lilihuigz16 小时前
Tutor LMS 4.0 Beta版全新上线:以学习者为中心的移动优先学习体验
学习·在线教育·lms
xingfujie16 小时前
运维实战攻略
运维
HHFQ16 小时前
在 systemd 场景下的 CPU 限制方式
linux
道清茗16 小时前
【RH294知识点汇总】第 9 章 《 自动执行 Linux 管理任务 》常见问题
linux·运维·服务器
山羊硬件Time16 小时前
自动化管理Linux的好工具:shell script
linux·嵌入式硬件·硬件工程师·基带工程·硬件开发
北方的流星16 小时前
华三路由器NAT配置
运维·网络·华三
wj30558537817 小时前
Codex + Git 开发环境配置指南(WSL版)
linux·运维·git
星马梦缘17 小时前
如何切换window-ubuntu双系统【方案二】
linux·运维·ubuntu
2501_9272835818 小时前
荣联汇智助力天津艺虹打造“软硬一体”智慧工厂,全流程自动化引领印刷包装行业数智变革
大数据·运维·数据仓库·人工智能·低代码·自动化
HXDGCL18 小时前
矩形环形导轨:自动化循环线的核心运动单元解析
运维·算法·自动化