Nginx cannot configure virtual hosts

Source: Internet
Author: User
Tags shebang
To configure m.test.com's {code...} root, it should be the root directory of the website.

To configure m.test.com

server {    listen 80; # IPv4    server_name m.test.com;    ## Parametrization using hostname of access and log filenames.    access_log logs/localhost_access.log;    error_log logs/localhost_error.log;    ## Root and index files.    root html/test;    index  index.php index.html index.htm;    ## If no favicon exists return a 204 (no content error).    location = /favicon.ico {        try_files $uri =204;        log_not_found off;        access_log off;    }            ## Don't log robots.txt requests.    location = /robots.txt {        allow all;        log_not_found off;        access_log off;    }    ## Try the requested URI as files before handling it to PHP.    location / {        ## Regular PHP processing.        location ~ \.php$ {            try_files  $uri =404;            fastcgi_pass   php_processes;            fastcgi_index  index.php;            fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;            include        fastcgi_params;        }        ## Static files        location ~* \.(?:css|gif|htc|ico|js|jpe?g|png|swf)$ {            expires max;            log_not_found off;            ## No need to bleed constant updates. Send the all shebang in one            ## fell swoop.            tcp_nodelay off;            ## Set the OS file cache.            open_file_cache max=1000 inactive=120s;            open_file_cache_valid 45s;            open_file_cache_min_uses 2;            open_file_cache_errors off;        }        ## Keep a tab on the 'big' static files.        location ~* ^.+\.(?:ogg|pdf|pptx?)$ {            expires 30d;            ## No need to bleed constant updates. Send the all shebang in one            ## fell swoop.            tcp_nodelay off;        }        } # / location} 

Root should be the root directory of the website.

Reply content:

To configure m.test.com

server {    listen 80; # IPv4    server_name m.test.com;    ## Parametrization using hostname of access and log filenames.    access_log logs/localhost_access.log;    error_log logs/localhost_error.log;    ## Root and index files.    root html/test;    index  index.php index.html index.htm;    ## If no favicon exists return a 204 (no content error).    location = /favicon.ico {        try_files $uri =204;        log_not_found off;        access_log off;    }            ## Don't log robots.txt requests.    location = /robots.txt {        allow all;        log_not_found off;        access_log off;    }    ## Try the requested URI as files before handling it to PHP.    location / {        ## Regular PHP processing.        location ~ \.php$ {            try_files  $uri =404;            fastcgi_pass   php_processes;            fastcgi_index  index.php;            fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;            include        fastcgi_params;        }        ## Static files        location ~* \.(?:css|gif|htc|ico|js|jpe?g|png|swf)$ {            expires max;            log_not_found off;            ## No need to bleed constant updates. Send the all shebang in one            ## fell swoop.            tcp_nodelay off;            ## Set the OS file cache.            open_file_cache max=1000 inactive=120s;            open_file_cache_valid 45s;            open_file_cache_min_uses 2;            open_file_cache_errors off;        }        ## Keep a tab on the 'big' static files.        location ~* ^.+\.(?:ogg|pdf|pptx?)$ {            expires 30d;            ## No need to bleed constant updates. Send the all shebang in one            ## fell swoop.            tcp_nodelay off;        }        } # / location} 

Root should be the root directory of the website.

Your name ism.test.com

Are you requesting www.test.com?

Ping m.test.com and check whether the echo is 127.0.0 .*

Also, have you rewritten/etc/hosts?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.