目录
1.添加conf.d配置子目录:
mkdir -p /etc/nginx/conf.d
2.在主配置文件中的server块前面导入conf.d
vim /etc/nginx/nginx.conf
# 修改内容
include /etc/nginx/conf.d/*.conf;
server {
...
}
3.添加页面文件
mkdir -p /usr/share/nginx/html/bbs;echo "This is shabi" > /usr/share/nginx/html/bbs/index.html
4.修改主配置文件:
cat << eof > /etc/nginx/conf.d/test.conf
# 测试配置
server {
listen 8080;
server_name localhost;
location / {
root html/bbs;
index index.html index.htm;
}
}
eof
5.检查:
nginx -t
6.重启服务:
systemctl restart nginx