php - 无法访问localhost?

查看:301
本文介绍了php - 无法访问localhost?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

使用的是本机 ubuntu nginx做web服务器,奈何前段时间一直好好的,突然就无法连接localhost了,查了很多资料也无解。
nginx服务处于开启状态如下:

$ sudo service nginx status
 * nginx is running

/etc/nginx/nginx.conf是默认的没有动过, 其中的include也对,如下:

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

/etc/nginx/site-available中的default,如下:

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

}

然后访问localhost就如下:

请问是如何解决呢


127.0.0.1也无法访问, 也没有开代理。

解决方案

Nginxubuntu下的架构不同于centoswindows, 通常nginx的所有站点配置都放在/etc/nginx/site-availabl目录下, 但是请注意, 这只是可用的配置, 若你想开启莫条站点的配置比如(www.test.com), 你需要在/etc/nginx/site-enabled创建软连接

$ pwd
/etc/nginx/site-enabled

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

软连接创建好后, 重庆NG

这篇关于php - 无法访问localhost?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆