* virtual hosting? 웹루트 폴더 제조기 (하나 이상제작_가상호스팅)
- 웹루트폴더? 크롬 등 웹브라우저로 접속이 가능
- 일반폴더? 웹브라우저로 접속 불가
* 80 => /web/site0/public 현재 이곳으로 연결되어있음.(디폴트)
8011과 8012 vhost를 만들고자 함.
1) sudo updatedb
2) sudo locate nginx.conf
3) cd /etc/nginx/conf.d (상기 경로)
4) sudo vim vhost.conf (끼워넣기로 aaa등 아무 글자 입력)
- 여기서 vhost(이름) 자리는 아무거나 입력해도 됨
5) sudo systemctl restart nginx => 오류 발생
* 오류 발생시 해당 오류 메시지 복사하고 붙여넣어 오류 원인 확인 가능
6) 상기 오류 해결 방법
sudo vim vhost.conf
| server { listen 8011; server_name _; location / { root /web/site1/public; } } server { listen 8012; server_name _; location / { root /web/site2/public; } } |
7) sudo systemctl restart nginx
=> 8011와 8012에 대해서도 포트포워딩 설정 필요

기존 HHTPD 호스트 포트 중복을 방지하기 위하여 8010으로 수정하였음
8) 7)까지 진행하면 409 에러 발생
9) 이전에 /web/site0/public처럼 파일을 만들어주어야 하는데, 복사 명령어를 사용하여 설정
cp -r site0 site1
cp -r site0 site2
ls
* cp 명령어 관련 참고 사이트
https://backendcode.tistory.com/307
10) echo "site0" > /web/site0/public/index.html
echo "site1" > /web/site1/public/index.html
echo "site2" > /web/site2/public/index.html
*sudo를 안쓰는 이유? koreast에게 소유권이 있기 때문
11) 127.0.0.1:8010/index.html
127.0.0.1:8011/index.html
127.0.0.1:8012/index.html

=> 성공적으로 접속된 것을 확인
'리눅스' 카테고리의 다른 글
| [리눅스] 폴더의 소유권과 설정파일 위치 변경 24.02.25 (2) | 2024.02.25 |
|---|---|
| [리눅스] nginx 파일 수정 (0) | 2024.02.24 |
| [리눅스] nginx index.html 파일 찾고 수정하기 (1) | 2024.02.24 |
| [리눅스] nginx 외부접속_24.02.24 (1) | 2024.02.24 |
| [리눅스] nginx 최신 버전 설치 24.02.18 (2) | 2024.02.24 |