Can't access localhost?

Source: Internet
Author: User

Use is the native Ubuntu nginx do Web server, but the previous period of time has been good, suddenly can not connect localhost, check a lot of data also no solution.
The Nginx service is enabled as follows:

$ sudo service nginx status * nginx is running

/etc/nginx/nginx.confIs the default is not moved, one of which is include also, as follows:

### Virtual Host Configs##include /etc/nginx/conf.d/*.conf;include /etc/nginx/sites-enabled/*;

/etc/nginx/site-availableThe default in, as follows:

server {    listen 80 default_server;    listen [::]:80 default_server ipv6only=on;    root /usr/share/nginx/html;    index index.html index.htm;    server_name localhost;    location / {        # First attempt to serve request as file, then        # as directory, then fall back to displaying a 404.        try_files $uri $uri/ =404;        # Uncomment to enable naxsi on this location        # include /etc/nginx/naxsi.rules    }    location ~ \.php$ {        fastcgi_split_path_info ^(.+\.php)(/.+)$;        # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini        # With php5-cgi alone:        fastcgi_pass 127.0.0.1:9000;        # With php5-fpm:        # kfastcgi_pass unix:/var/run/php5-fpm.sock;        fastcgi_index index.php;        include fastcgi_params;    }    # deny access to .htaccess files, if Apache's document root    # concurs with nginx's one}

Then visit localhost as follows:

How is it solved?

127.0.0.1 also cannot access or open an agent.

Reply content:

Use is the native Ubuntu nginx do Web server, but the previous period of time has been good, suddenly can not connect localhost, check a lot of data also no solution.
The Nginx service is enabled as follows:

$ sudo service nginx status * nginx is running

/etc/nginx/nginx.confIs the default is not moved, one of which is include also, as follows:

### Virtual Host Configs##include /etc/nginx/conf.d/*.conf;include /etc/nginx/sites-enabled/*;

/etc/nginx/site-availableThe default in, as follows:

server {    listen 80 default_server;    listen [::]:80 default_server ipv6only=on;    root /usr/share/nginx/html;    index index.html index.htm;    server_name localhost;    location / {        # First attempt to serve request as file, then        # as directory, then fall back to displaying a 404.        try_files $uri $uri/ =404;        # Uncomment to enable naxsi on this location        # include /etc/nginx/naxsi.rules    }    location ~ \.php$ {        fastcgi_split_path_info ^(.+\.php)(/.+)$;        # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini        # With php5-cgi alone:        fastcgi_pass 127.0.0.1:9000;        # With php5-fpm:        # kfastcgi_pass unix:/var/run/php5-fpm.sock;        fastcgi_index index.php;        include fastcgi_params;    }    # deny access to .htaccess files, if Apache's document root    # concurs with nginx's one}

Then visit localhost as follows:

How is it solved?

127.0.0.1 also cannot access or open an agent.

Nginxubuntuunder the schema differs from centos or, the windows usual nginx all-site configuration is placed in the /etc/nginx/site-availabl directory, but note that this is only a usable configuration, if you want to open the configuration of the MO-site such as ( www.test.com ), you need to /etc/nginx/site-enabled create软连接

$ pwd/etc/nginx/site-enabled$ sudo ln -s /etc/nginx/site-availabl/www.test.com www.test.com

Soft connect created well after Chongqing NG ,

Find out if there's 127.0.0.1 locahost.
No, No.

# echo "127.0.0.1 locahost" >> /etc/hosts

Solved, but not quite understood;
I site-available default copied a copy of the file into/etc/nginx/conf.d/default.conf
And then

sudo nginx -tsudo service nginx restart

You can do it. Is it /etc/nginx/conf.d /etc/nginx/site-available OK to write the configuration file in any directory with them?

Is it a firewall setup problem?

  • 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.