Nginx 다 중 사이트 설정 소결 지원
8177 단어 분류 되 지 않 음
여기 서 2 개의 사이트 (2 개의 도 메 인 이름) 를 설정 하 는 것 을 예 로 들 면 n 개의 사이트 가 상응 하 게 조정 할 수 있 습 니 다. 가설:
IP : 202.55.1.100
1 example1.com /opt/nginx/html/example1.com
2 example2.com /opt/nginx/html/example2.com
[편집] 기본 발상
우선 도 메 인 이름 A 기록 을 이 IP 로 해석 해 야 합 니 다. 이 때 가능 합 니 다.http://example1.com형식 접근, cname 기록 추가, 보증http://www.example1.com이런 형식 으로 도 방문 할 수 있다
참고 그림:
그리고 두 사이트 의 파일 example 1. com, example 2. com 을 nginx 가 접근 할 수 있 는 디 렉 터 리 에 놓 습 니 다. 예 를 들 어 / opt / nginx / html.
각 사이트 에 각각 nginx 프로필 example 1. com. conf, example 2. com. conf 를 만 들 고 설정 파일 을 / opt / nginx / conf / vhosts / 디 렉 터 리 에 놓 습 니 다.
그리고 / opt / nginx / conf / nginx. conf 에 include 를 추가 하여 2 단계 로 만 든 프로필 을 모두 포함 합 니 다 (* 번호 로)
다시 시작 nginx
[편집] 구체 적 인 과정
vhosts 디 렉 터 리 mkdir / opt / nginx / conf / vhosts 를 만 들 고 vhosts 디 렉 터 리 아래 example 1. com. conf 라 는 파일 을 만 들 고 다음 내용 을 복사 합 니 다.
server {
listen 80;
server_name example1.com www.example1.com;
access_log /opt/nginx/html/example1.log;
location /{
root /opt/nginx/html/example1.com;
index index.php index.html;
}
error_page 500502503504/50x.html;
location = /50x.html {
root /opt/nginx/html;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /opt/nginx/html/example1.com$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}}
네 것 으로 바 뀌 면 네 곳 을 고 쳐 야 한다.
vhosts 디 렉 터 리 에 example 2. com. conf 라 는 파일 을 만 들 고 다음 내용 을 복사 하거나 이전 파일 수정 을 복사 해도 됩 니 다.
server {
listen 80;
server_name example2.com www.example2.com;
access_log /opt/nginx/html/example2.log;
location /{
root /opt/nginx/html/example2.com;
index index.php index.html;
}
error_page 500502503504/50x.html;
location = /50x.html {
root /opt/nginx/html;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /opt/nginx/html/example2.com$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}}
/ opt / nginx / conf / nginix. conf 파일 을 열 고 해당 위치 (http 의 대괄호 가 끝나 기 전에) include 이상 2 개의 파일 을 엽 니 다.
include /opt/nginx/conf/vhosts/*.conf;
마지막 으로 Nginx 를 다시 시작 하면 됩 니 다.
빠 른 설치 PHP, MySQL, Nginx, phpmyadmin 참조
html 에 있 는 phpmyadmin 에 직접 접근 하려 면
ln -s /opt/nginx/html/phpmyadmin /opt/nginx/html/example1.com/phpmyadmin
물론 새 사이트 admin 에 phpmyadmin 을 저장 하 는 것 이 좋 습 니 다. 예 를 들 어 / opt / nginx / html / admin / phpmyadmin 을 저장 하고 통과 하 는 것 이 좋 습 니 다.http://admin.elesos.com/phpmyadmin/index.php방문 하 다.
[편집] 예 수 는 참고.
http://www.vpsee.com/2009/06/nginx-virtual-hosting-configuration/
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Nginx 다 중 사이트 설정 소결 지원어떻게 웹 서버 를 설정 해야만 하나의 VPS 에 여러 개의 사이트 / 블 로 그 를 설치 할 수 있 습 니까?어떻게 IP 를 통 해 여러 사이트 / 도 메 인 이름 을 방문 합 니까?대부분의 웹 서버 가 지원 하 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.