웹사이트 파일이 있는 서버 블록 대신 기본 서버 블록이 계속 로드됩니다.

웹사이트 파일이 있는 서버 블록 대신 기본 서버 블록이 계속 로드됩니다.

Ubuntu에 nginx를 새로 설치했기 때문에 크게 혼란을 겪지 않았으며 대부분의 튜토리얼은 DigitalOcean 웹 사이트에서 가져왔습니다. 두 개의 서버 블록을 설정했지만(첫 번째는 기본값이고 두 번째는 내 웹 사이트용) 일부 문제로 인해 보조 서버 블록에 있는 웹 사이트를 호출하더라도 기본 서버 블록이 계속 로드됩니다. 내 웹사이트는 yoalfaaz.com이고 이를 로드하려고 하면 기본 서버의 파일이 로드됩니다.

더 명확하게 말하면 의 파일이 /var/www/html계속 로드되는 대신 /var/www/yoalfaaz.com/html.

sites-available/yoalfaaz.com파일 은 여기 있어요

server {
        listen 80 ;
        listen [::]:80 ;

        root /var/www/yoalfaaz.com/html;

        # Add index.php to the list if you are using PHP
        index index.php index.html index.htm index.nginx-debian.html;

        server_name yoalfaaz.com www.yoalfaaz.com;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #

        location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        }

        location ~ /\.ht {
        deny all;
        }
}

그리고 여기에 error.log 메시지가 있습니다.

2018/02/18 06:47:02 [error] 28275#28275: *1656 directory index of "/var/www/html/" is forbidden, client: 47.89.22.200, server: [IP for server], request: "GET / HTTP/1.0", host: "www.yoalfaaz.com", referrer: "https://www.yoalfaaz.com"

나는 또한 명령을 사용했으며 nginx -t모든 것이 좋습니다. 그렇다면 여기서 문제가 무엇인지 말씀해 주시겠습니까?

답변1

에서 파일에 대한 심볼릭 링크를 생성하는 데 몇 가지 문제가 있었습니다 sites-enabled. 그래서 sites-enabled명령에서 파일을 제거했습니다.

sudo rm /etc/nginx/sites-enabled/yoalfaaz.com

그런 다음 다음 명령을 사용하여 다시 심볼릭 링크를 만들었습니다.

sudo ln -s /etc/nginx/sites-available/yoalfaaz.com /etc/nginx/sites-enabled/

모든 것이 다시 작동하기 시작했습니다.

관련 정보