Apache(七)使用auth_dbm

一、AuthDBMUserFile

<AuthnProviderAlias file ufile>

AuthUserFile /root/apache2/auth/userfile

</AuthnProviderAlias>


<Directory /root/apache2/htdoc>

AllowOverride None

AuthType Basic

AuthName "Entry username and password"

AuthBasicProvider ufile

     Require valid-user

</Directory>


假如有成百上千个用户在userfile文件中,那么使用这种方式效率极低,应使用

 

AuthDBMUserFile,使用步骤如下


1.1 使用htdbm生成dbm文件

./htdbm -bc /root/apache2/auth/userdbm dbm1 dbm1


上述命令将生成userdbm.dir和userdbm.pag文件,并创建用户dbm1,密码dbm1


1.2 配置AuthDBMUserFile

<Directory /root/apache2/htdoc>

AllowOverride None

AuthType Basic

AuthName "Entry username and password"

AuthBasicProvider dbm

AuthDBMUserFile /root/apache2/auth/userdbm

</Directory>


按照上述配置后,访问资源需提供userdbm中存在的用户。

 

二、AuthDBMGroupFile


<Directory /root/apache2/htdoc>

AllowOverride None

AuthType Basic

AuthName "Entry username and password"

AuthBasicProvider dbm

     AuthDBMUserFile /root/apache2/auth/userdbm

AuthGroupFile /root/apache2/auth/groupfile

Require group group1

</Directory>


上述指定只有组group1中的用户可访问资源,同样,如果groupfile中的数据很多,

 

效率也会很低,应使用AuthDBMGroupFile,使用如下

 

<Directory /root/apache2/htdoc>

AllowOverride None

AuthType Basic

     AuthName "Entry username and password"

     AuthBasicProvider dbm

     AuthDBMUserFile /root/apache2/auth/userdbm

AuthDBMGroupFile /root/apache2/auth/groupfile

     Require group group1

</Directory>

 

 

注:当使用AuthBasicProvider dbm时,原AuthUserFile即使指定了apache也不会加载使用其中的用户!

# LAMP Auto Install Script for CentOS 7 #centos7下编写自动化脚本搭建lamp架构,下载目录为/opt/lamp1/,需求版本:apache-2.4.63、php-7.4.33、mysql-8.0.41-1.el9.x86_64.rpm-bundle.tar,php不用单独启动,和apache联动即可 #要求: #安装apache和php的依赖模块apr-1.7.5、apr-util-1.6.3、ibiconv-1.15、libmcrypt-2.5.8、mhash-0.9.9.9、mcrypt-2.6.8、libmcrypt-devel并做好环境变量和软连接 #apache开启模块如下模块并解决依赖问题{ core_module (static) so_module (static) http_module (static) mpm_prefork_module (static) authn_file_module (shared) authn_core_module (shared) authz_host_module (shared) authz_groupfile_module (shared) authz_user_module (shared) authz_core_module (shared) access_compat_module (shared) auth_basic_module (shared) socache_shmcb_module (shared) socache_dbm_module (shared) reqtimeout_module (shared) filter_module (shared) mime_module (shared) log_config_module (shared) env_module (shared) expires_module (shared) headers_module (shared) setenvif_module (shared) version_module (shared) ssl_module (shared) unixd_module (shared) status_module (shared) autoindex_module (shared) dir_module (shared) alias_module (shared) rewrite_module (shared) php5_module (shared) proxy_module (shared) proxy_ajp_module (shared) proxy_balancer_module (shared) proxy_connect_module (shared) proxy_http_module (shared) slotmem_shm_module (shared)} #php开启模块如下模块并解决依赖问题{bcmath bz2 Core ctype curl date dom ereg fileinfo filter gd gettext hash iconv json libxml mbstring mcrypt mhash mysql mysqli mysqlnd openssl pcntl pcre PDO pdo_mysql pdo_sqlite Phar posix Reflection session shmop SimpleXML soap sockets SPL sqlite3 standard sysvmsg sysvsem sysvshm tokenizer xml xmlreader xmlwriter zip zlib} #验证apache和php联动访问,MySQL登录和初始化、密码设置为1hblsqt2zhlmcl#@!
最新发布
03-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值