nginx虚拟机无法访问解决

1、重要:修改配置文件使用虚拟机,否则怎么配置都不生效,添加如下用户

[root@host-10-1-1-161 html]# ll /etc/nginx/nginx.conf
-rw-r--r-- 1 root root 345 Aug 26 10:41 /etc/nginx/nginx.conf
[root@host-10-1-1-161 html]# vi /etc/nginx/nginx.conf
user root root;                    #说明:这里的user根据 自己的nginx.conf文件所在的目录的属主属性而定 
worker_processes 1;


2、其他目录下的 html文件,必须写成 index.html 否则无法访问


[root@host-10-1-1-161 ~]# curl http://127.0.0.1:8080
<html>
<head><title>403 Forbidden</title></head>
<body bgcolor="white">
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx/1.12.2</center>
</body>
</html>
[root@host-10-1-1-161 ~]# mv /web/sing/sina.html /web/sing/index.html
[root@host-10-1-1-161 ~]# 
[root@host-10-1-1-161 ~]# curl http://127.0.0.1:8080
<html>
<p>
this is my nginx
</p>
</html>

 

转载于:https://www.cnblogs.com/effortsing/p/10012447.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值