
nginx를 사용하는 가상 호스팅에 문제가 있습니다. 무엇을 하든 www/example1 폴더 대신 www/html에 액세스합니다. 누구든지 문제가 무엇인지 알아낼 수 있습니까? 내가 뭐 놓친 거 없니?
pi@homeserver:/etc/nginx/sites-enabled $ ls -l
total 4
-rw-r--r-- 1 root root 467 Sep 4 19:41 default
lrwxrwxrwx 1 root root 38 Sep 4 19:43 example1 -> /etc/nginx/sites-available/example1
기본 파일은 다음과 같습니다.
server {
listen 80;
root /var/www/html;
index index.php index.html index.htm;
server_name localhost;
location / {
try_files $uri $uri/ =404;
}
location ~\.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
try_files $uri =404;
include fastcgi_params;
}
}
example1 파일은
server {
listen example1.com:80;
root /var/www/example1.com;
index index.php index.html index.htm;
server_name example1.com www.example1.com;
location / {
try_files $uri $uri/ =404;
}
location ~\.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
try_files $uri =404;
include fastcgi_params;
}
}
로그에 이 오류가 표시됩니다.
2016/09/04 21:41:08 [emerg] 1788#0: invalid host in "http://www.example1.com:80" of the "listen" directive in /etc/nginx/sites-enabled/example1.com:2
답변1
오류 메시지를 보면 해당 명령문을 IP 주소로 nginx
구문 분석하는 것이 어려운 것으로 보입니다.listen example1.com:80;
listen
멀티홈 서버가 있고 서비스를 단일 인터페이스로 제한하려는 경우 지시문에 IP 주소를 제공하는 것이 유용합니다.
대부분의 경우 이 설명 listen 80;
으로 충분합니다. 두 서버 블록 모두에 다음을 사용하는 것이 좋습니다.
server {
listen 80;
...
}
바라보다이 파일더 알아보기.