2021/3/30 晚上
今天在一台主机上打算部署http服务,各方面都做好准备后想测试一下能不能访问到站点,然后给我报了401错误,完整错误如下:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>401 Unauthorized</title>
</head><body>
<h1>Unauthorized</h1>
<p>This server could not verify that you
are authorized to access the document
requested. Either you supplied the wrong
credentials (e.g., bad password), or your
browser doesn't understand how to supply
the credentials required.</p>
</body></html>
我们知道401错误是客户端请求没有经过授权,所以很快就能知道原因
查看一下相关配置文件
[root@RS1 ~]# vim /etc/httpd/conf/httpd.conf
问题找到了,一般网页是放在 /var/www/html 目录下的,而我在上次做apache的用户认证机制时候把站点根目录改成了/data/www/html,但是这次我的站点是放在了/var/www/html 目录下,所以才会出现这种情况
再curl一下
[root@RS1 ~]# curl 192.168.xxx.xxx
RS1
成功解决啦!!