네임서버에 해당 서브도메인을 등록해둔 상태입니다.
sub1.domain.com 이런 형태로 되어있고, 서버의 IP를 등록해두었습니다.
그리고 서버에 돌아가는 Nginx 설정파일인 Conf 파일은 아래와 같습니다.
domain.com (메인페이지) / main.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
server {
listen 80;
server_name domain.com www.domain.com;
root /usr/share/nginx/html/main;
location / {
index index.php index.html;
}
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
|
cs |
sub1.domain.com (서브페이지) / sub1.conf
1
2
3
4
5
6
7
8
9
10
|
server {
listen 80;
server_name sub1.domain.com;
root /usr/share/nginx/html/sub1;
location / {
index index.php index.html;
}
}
|
|
이것 이외의 conf 파일은 없습니다.
어느 부분을 수정해야 서브도메인 연결을 할 수 있을까요?
1. 서브도메인을 인식하는 부분은 잘 만들어져 있는 것 같은데요. 설정파일 추가/수정 후 nginx 재시작하셨나요?
2. PHP 연동하는 부분도 마찬가지로 복사해 넣어 주셔야 합니다.