lamp----3 访问控制

1基于ip的

vi /etc/httpd/conf/httpd.conf       #改配置文件最好在最后写。。

<Directory "/web/upload">
AllowOverride None
# Allow open access:
Require all granted
Order deny,allow
Deny from all
Allow from 192.168.1.141
</Directory>

systemctl restart httpd.service

不是144的主机不能登陆。。。

2基于用户的

vi /etc/httpd/conf/httpd.conf

<Directory "/web/upload">
AuthName "hello"
AuthType basic
AuthUserFile /etc/httpd/.htpasswd
Require valid-user
</Directory>

htpasswd -cm /etc/httpd/.htpasswd aaa    #  使用htpasswd创建aaa用户  第一次创建需要-c。。以后不需要

htpasswd -m /etc/httpd/.htpasswd bbb     #创建bbb

htpasswd -D /etc/httpd/.htpasswd bbb      #删除bbb用户

systemctl restart httpd.service

登陆测试

原文地址:https://www.cnblogs.com/han1094/p/6367742.html