无法访问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也无法访问, 也没有开代理。
回复内容:
使用的是本机 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也无法访问, 也没有开代理。
Nginx
在ubuntu
下的架构不同于centos
或windows
, 通常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
,
$ cat /etc/hosts
找一下 有没有 127.0.0.1 locahost
没有的话
# echo "127.0.0.1 locahost" >> /etc/hosts
解决了,但是不太理解;
我把site-available
中的default
文件 复制一份到/etc/nginx/conf.d/default.conf
然后
sudo nginx -t
sudo service nginx restart
就可以了。 不是说/etc/nginx/conf.d
与/etc/nginx/site-available
在他俩任何目录下写配置文件,都可以吗?
是不是防火墙设置问题呢?
上一篇: phpcms 图片上传不成功问题
下一篇: 中篇:安装及配置PHP_PHP教程
推荐阅读
-
更改localhost为其他名字的方法_php技巧
-
数据库连接问题未找到或无法访问服务器
-
Docker容器安装的mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost'
-
织梦平台搭建好,输入http://localhost/登陆不了后台
-
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
-
mysql授权localhost&%区别及一直授权错误解决办法(安装openstack有感)_MySQL
-
无法访问 您可能没有权限使用网络资源 帖几个PHP的无限分类实现想法~
-
php 环境本地用ip连接mysql响应快,用localhost连接慢的解决
-
eclipse中部署在tomcat上的项目能正常运行,但无法访问tomcat默认首页
-
梦蝶一元购该怎么配置啊?它的根目录老指向localhost