Не могу настроить nginx

Рейтинг: 1Ответов: 1Опубликовано: 05.04.2015

Здравствуйте, у меня не получается настроить домены и субдомены. При данных настройках, по адресу "www.laravel-ev.com" появляется сообщение, что "Веб-страница недоступна", но если изменить во втором блоке server_name на

server_name localhost 

тогда, при переходе на localhost я вижу свой сайт.

Файл: /etc/nginx/sites-available/default

server {
    listen          80;
    server_name     www.laravel-ev.com;

    return 301 $scheme://laravel-ev.com$request_uri;
}

server {

    listen          80;
    server_name     laravel-ev.com *.laravel-ev.com;

    access_log      /var/log/nginx/laravel-ev/access.log;
    error_log       /var/log/nginx/laravel-ev/error.log;
    rewrite_log     on;

    root /var/www/laravel/ev/public;
    index index.php;

    # Added cache headers for images, quick fix for cloudfront.

    location ~* \.(png|jpg|jpeg|gif)$ {

        expires 30d;
        log_not_found off;

    }

    # Only 3 hours on CSS/JS to allow me to roll out fixes during
    # early weeks.

    location ~* \.(js|css|ico)$ {

        expires 3h;
        log_not_found off;

    }

    # Heres my redirect, try normal URI and then our Laravel urls.
    location / {

        try_files $uri $uri/ /index.php?$query_string;

        # A bunch of perm page redirects from my old        
        # site structure for SEO purposes. Not interesting.

    }


    # Look below for this. I decided it was common to Laravel
    # sites so put it in an extra template.

    include /etc/nginx/templates/laravel4;
}

Файл: /etc/nginx/templates/laravel4;

    location ~* \.php$ {

            # Server PHP config.
            fastcgi_pass                    unix:/var/run/php5-fpm.sock;
            fastcgi_index                   index.php;
            fastcgi_split_path_info         ^(.+\.php)(.*)$;

            # Typical vars in here, nothing interesting.

            include                         /etc/nginx/fastcgi_params;
            fastcgi_param                   SCRIPT_FILENAME $document_root$fastcgi_script_name;

    }

    location ~ /\.ht {

            # Hells no, we usin nginx up in this mutha. (deny .htaccess)
            deny all;

    }

Ответы

▲ 1Принят

@geekartemiy, когда ваш браузре обращается по адресу www.laravel-ev.com, он обращается к dns-серверам, чтобы выяснить конечную машину, к которой обратиться, и смотрит при этом во внешний интернет, в котором о таком хосте ни сном и ни духом. Вам нужно так или иначе обмануть DNS-систему, проще всего добавить следующую pапись в /etc/hosts или C:/WINDOWS/system32/drivers/etc/hosts (в зависимости от ОС):

127.0.0.1 www.laravel-ev.com laravel-ev.com

или поставить и настроить DNS-сервер, например, dnsmasq (это уже на следующей ступени по сложности).