Nginx 포트 별 가상 호스트 설정
시스템 환경 및 nginx 버 전:
[root@localhost nginx-1.15.5]# uname -r && cat /etc/redhat-release
3.10.0-693.el7.x86_64
CentOS Linux release 7.4.1708 (Core)
[root@localhost nginx-1.15.5]# nginx -v
nginx version: nginx/1.15.5
프로필 을 수정 하고 다음 내용 을 추가 합 니 다.
[root@localhost nginx-1.15.5]# vim /usr/local/nginx/conf/nginx.confv
···
server {
listen 8080;
server_name localhost;
root /usr/share/nginx/html;
}
server {
listen 8081;
server_name localhost;
root /usr/share/nginx/html1;
}
server {
listen 8082;
server_name localhost;
root /usr/share/nginx/html2;
}
···
각각 nginx 루트 디 렉 터 리 에 접근 할 파일 만 들 기:
[root@localhost nginx-1.15.5]# ll /usr/share/nginx/html*/index.html
-rw-r--r-- 1 root root 613 Nov 29 17:06 /usr/share/nginx/html1/index.html
-rw-r--r-- 1 root root 614 Nov 29 17:06 /usr/share/nginx/html2/index.html
-rw-r--r-- 1 root root 610 Nov 29 16:36 /usr/share/nginx/html/index.html
nginx 다시 시작:
[root@localhost nginx-1.15.5]# nginx -s stop && nginx
브 라 우 저 각각 열기:http://192.168.1.117:8080/ http://192.168.1.117:8081/ http://192.168.1.117:8082/
END