apache 用户登录认证

简介: 在Redhat 9系统中,已安装Apache服务。遵循教程,首先创建用户"DL"并设置密码,然后创建用户目录/home/DL/public_html,存放index.html。启用Apache的userdir模块,取消UserDir disabled的注释,并重启服务。通过htpasswd创建用户认证文件,编辑userdir.conf添加权限设置,包括AllowOverride、authuserfile、authname、authtype和require user。最后,通过浏览器访问ip/~DL/进行测试,实现用户登录验证。


前提条件
1、阿帕奇服务安装完成

参考:https://developer.aliyun.com/article/1481055?spm=a2c6h.13148508.setting.33.274b4f0eb32TmA

环境

Redhat 9

步骤:
通过userdir模块,共享目录资料

创建用户

[root@admin ~]# useradd DL
[root@admin ~]# passwd DL
更改用户 DL 的密码 。
新的密码:
无效的密码: 密码是一个回文
重新输入新的密码:
passwd:所有的身份验证令牌已经成功更新。
[root@admin ~]#
创建用户目录并授权以及index.html文件

html代码获取地址:总结了一些 html(H5) 各种 炫酷代码_h5代码-CSDN博客

[root@admin ~]# mkdir /home/DL/public_html
[root@admin ~]# chmod 711 /home/DL/
[root@admin ~]# chmod 755 /home/DL/public_html/
[root@admin ~]# vim /home/DL/public_html/index.html
[root@admin ~]#
修改userdir模块配置文件

重启服务验证是否以启用

[root@admin ~]# vim /etc/httpd/conf.d/userdir.conf
17 # UserDir disabled //注释掉这一行
18
19 #
20 # To enable requests to /~user/ to serve the user's public_html
21 # directory, remove the "UserDir disabled" line above, and uncomment
22 # the following line instead:
23 #
24 UserDir public_html //启用这一行
25
[root@admin ~]# systemctl restart httpd.service
访问测试 ip/~用户名/

增加登录用户

htpasswd命令是建立和更新存储用户名、密码的文本文件, 用于对HTTP用户的basic认证。

[root@admin ~]# htpasswd -c /etc/httpd/passwd DL
New password:
Re-type new password:
Adding password for user DL
增加登录认证配置、重启服务

注释掉原有的三行、增加如下配置

[root@admin ~]# vim /etc/httpd/conf.d/userdir.conf
31
32 # AllowOverride FileInfo AuthConfig Limit Indexes
33 # Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
34 # Require method GET POST OPTIONS
35 AllowOverride all //允许的相关指令
36 authuserfile "/etc/httpd/passwd" //验证登录密码的路径
37 authname "欢迎光临!" //信息提示
38 authtype basic //密码类型
39 require user DL //指定的登录用户
40
[root@admin ~]# systemctl restart httpd.service
浏览器测试 ip/~用户名/

登录成功!

目录
相关文章
|
XML 存储 缓存
Spring认证中国教育管理中心-Apache Geode 的 Spring 数据教程一
Spring认证中国教育管理中心-Apache Geode 的 Spring 数据教程一
|
存储 XML NoSQL
Spring认证中国教育管理中心-Apache Cassandra 的 Spring 数据教程十
Spring认证中国教育管理中心-Apache Cassandra 的 Spring 数据教程十
|
NoSQL 安全 Java
Spring认证中国教育管理中心-Apache Cassandra 的 Spring 数据教程六
Spring认证中国教育管理中心-Apache Cassandra 的 Spring 数据教程六
|
存储 XML 缓存
Spring认证中国教育管理中心-Apache Cassandra 的 Spring 数据教程四
Spring认证中国教育管理中心-Apache Cassandra 的 Spring 数据教程四
|
存储 NoSQL 安全
Spring认证中国教育管理中心-Apache Cassandra 的 Spring 数据教程四
Spring认证中国教育管理中心-Apache Cassandra 的 Spring 数据教程四
|
NoSQL Apache 数据库
9.25直播预告|如何0基础获得Apache Cassandra Administrator国际认证?
本次技术直播将为您分享如何0基础获得Cassandra Administrator国际认证的考试经验。
1248 0
9.25直播预告|如何0基础获得Apache Cassandra Administrator国际认证?
|
Apache
权限认证框架之Apache Shiro
1介绍 Shiro 架构图
1015 0
|
应用服务中间件 PHP Apache

推荐镜像

更多