单机部署多个 nginx

为方便测试,单机部署多个 nginx,监听不同端口,响应不同页面。以其中一个为例:

1、新建目录:

/root/nginx/8571/
/root/nginx/8571/html/
/root/nginx/8571/log/

2、将文件:/usr/sbin/nginx 拷贝至 /root/nginx/8571/
3、修改默认 html 内容:/root/nginx/8571/html/index.html

在这里插入图片描述

4、新建配置文件:/root/nginx/8571/nginx.conf

在这里插入图片描述

注意:

若 nginx.conf 配置 location 后,重启 nginx 再访问,如果访问提示:Nginx 403 Forbidden,则需要在 nginx.conf 头部加入一行:

user root;