人生难得几回搏,此时不搏待何时。这篇文章主要讲述Linux系统基础知识(13)Web网站服务管理相关的知识,希望能为你提供帮助。
1.客户端地址限制通过Require配置项实现也止限制功能
- Require all granted:表示所有主机允许访问
- Require all denied:表示拒绝所有主机访问
- Require local:表示仅允许本地主机访问
- Require [not] host < 主机名或域名列表> :
- Require [not] ip < IP地址或网段列表>
环境:编译安装Apache??https://blog.51cto.com/u_15630500/5296651??
- 修改配置文件
[root@localhost ~]#vim /usr/local/httpd/conf/httpd.conf//配置文件路径
#254行前添加
< RequireALL>
Require all granted
Require not ip 192.168.19.102
< /RequireALL>
[root@localhost conf]# systemctl restart httpd
- 客户端配置访问:
[root@localhost ~]# yum -y install elinks
[root@localhost ~]# elinks 192.168.19.100
192.168.19.103
[root@localhost ~]# yum -y install elinks
[root@localhost ~]# elinks 192.168.19.100
2.用户权限管理
[root@localhost httpd]# ll /usr/local/httpd/bin
使用htppasswd创建用户
[root@localhost httpd]# htpasswd -c /usr/local/httpd/conf/.awspwd webadmin
New password:
Re-type new password:
Adding password for user webadmin
[root@localhost httpd]# htpasswd/usr/local/httpd/conf/.awspwd test
New password:
Re-type new password:
Adding password for user test
[root@localhost httpd]# vim /usr/local/httpd/conf/httpd.conf
#254行前添加
AuthName "DocumentRoot"
AuthType Basic
AuthUserFile /user/local/httpd/conf/.awspwd
Require webadmin
- AuthName:定义受保护的领域名称,该内容将在浏览器弹出的认证对话框中显示
- AuthType:认证类型,Basic表示基本认证
- AuthUserFile:这种用户账户,密码的路径
- Require valied-user:用户访问
[root@localhost ~]#elinks 192.168.19.100
3.虚拟web主机环境准备:
[root@localhost httpd]# mkdir -p /var/www/html/blab1.com
[root@localhost httpd]# mkdir -p /var/www/html/blab2.com
[root@localhost httpd]# echo "< h1> www.blab1/com< /h1> " > /var/www/html/blab1.com/index.html
[root@localhost httpd]# echo "< h1> www.blab2/com< /h1> " > /var/www/html/blab2.com/index.html
192.168.19.103
[root@slave1 ~]# echo "192.168.19.100 www.blab1.com" > > /etc/hosts
[root@slave1 ~]# echo "192.168.19.100 www.blab2.com" > > /etc/hosts
修改配置文件:
[root@localhost httpd]# vim/usr/local/httpd/conf/extra/httpd-vhosts.conf
< VirtualHost *:80>
ServerAdmin www.blab1.com
DocumentRoot "/var/www/html/blab1.com"
ServerName www.blab1.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/www.blab1.com-error_log"
CustomLog "logs/www.blab1.com-access_log" common
< Directory "/var/www/html">
Require all granted
< /Directory>
< /VirtualHost>
< VirtualHost *:8080>
ServerAdmin www.blab2.com
DocumentRoot "/var/www/html/blab2.com"
ServerName www.blab2.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/www.blab2.com-error_log"
CustomLog "logs/www.blab2.com-access_log" common
< Directory "/var/www/html">
Require all granted
< /Directory>
< /VirtualHost>
启用配置文件:
[root@localhost httpd]# vim /usr/local/httpd/conf/httpd.conf
Listen 8080//53行附近添加
Include conf/extra/httpd-vhosts.conf//486行附近开启
[root@localhost httpd]# systemctl restarthttpd.service
192.168.19.103测试
[root@localhost ~]# elinks www.blab1.com
[root@localhost ~]# elinks www.blab2.com
[root@localhost ~]#elink 192.168.19.100:8080
【Linux系统基础知识(13)Web网站服务管理】
推荐阅读
- 看Feign的源码一定要看这个类
- 算法题每日一练---第51天(找不同)
- Zabbix对Linux主机监控
- keepalived配置文件解析#Word文档导入#
- CMU 15-445 数据库课程第三课文字版 - 存储1
- Harmony OSArkUIets开发 创建视图与构建布局
- 怎么在图片上编辑文字(超简单的两种编辑方法都教给你!)
- Unity集成华为游戏服务SDK方式(Unity导出为Android工程)
- Splunk深度专题(疫情下的可观测)