Mac下配置nginx域名转发教程
1. 修改hosts文件
1.打开host文件:
sudo vim hosts
2.添加域名映射
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
# 添加本地域名映射
127.0.0.1 www.lzl.com
2.配置nginx虚拟主机
默认首页,从JD官网下载了一个静态的html页面来测试。
server {
listen 80; # 监听端口
<font color=red> server_name www.lzl.com; </font> # ip或域名
#access_log logs/host.access.log main;
location / { #
root /usr/local/Cellar/nginx/1.19.10/jd/; #
index jd.html; #
}
error_page 500 502 503 504 /50x.html; #
location = /50x.html {
root html;
}
}
3. 访问验证
浏览器输入:www.lzl.com