下载nginx
brew install nginx
配置nginx文件
打开配置文件所在文件夹
open /opt/homebrew/etc/nginx/
配置nginx.conf
# 设置user root owner;才能访问静态资源
user root owner;
server {
listen 80;
#你要访问的域名
server_name bdw-dcdn.bingdou.site;
location / {
#本地资源的地址
root /Users/fengruixiang/Desktop/tb_layui/company;
index index.html index.php;
}
}
配置hosts
sudo vim /etc/hosts
执行nginx
sudo nginx //启动
sudo nginx -s stop //停止
sudo nginx -s reload // 重启