域名访问流程:
1. 访问hosts(主机),查看本地DNS缓存,有则直接访问
2. 本地无缓存,则查看localDNS(/etc/resolv.conf文件,或IP配置文件)
3. 在查看权威DNS,获取域名对应ip
Apache相关配置
:
(1):虚拟主机
环境:test1主机 IP:192.168.10.11;test2主机 IP:192.168.10.12
配置文件:/etc/httpd/conf/httpd.conf
准备(test1,test2):
yum install httpd -y
systemctl start httpd
[root@test1 ~]# vim /etc/httpd/conf/httpd.conf #插入下面此信息
...
80 <VirtualHost *:80>
81 DocumentROOT /var/www/test #配置文件目录
82 serverNAME www.test.com #配置的域名
83 </VirtualHost>
...
[root@test1 test]# systemctl restart httpd
[root@test1 ~]# cd /var/www/
[root@test1 www]# mkdir test
[root@test1 www]# cd test/
[root@test1 test]# vim index.html
1 This is a test of test!
#测试:
[root@test2 ~]# curl 192.168.10.11
This is a test of test!
[root@test2 ~]# curl www.test.com
^C
#注:此时需要在test2上面添加下面信息
[root@test2 ~]# vim /etc/hosts
3 192.168.10.11 www.test.com
#测试
[root@test2 ~]# curl www.test.com
This is a test of test!
#用主机测试
此时需要配置主机文件,因为主机不能解析域名信息
配置文件为:C:\Windows\System32\drivers\etc\hosts
测试:
(2)apache的页面认证
配置:
[root@test1 test]# vim /etc/httpd/conf/httpd.conf #插入以下几行
117 <Directory /var/www/>
118 Options None
119 AllowOverride none
120 Order allow,deny
121 Allow from all
122 AuthName "please input username && passwd.."
123 AuthType Basic
124 AuthUserFile /usr/local/httpd/conf/passwd
125 require valid-user
126 # Require all denied
127 </Directory>
[root@test1 test]# systemctl restart httpd
[root@test1 test]# vim /var/local/httpd/conf/passwd
[root@test1 test]# mkdir -p /var/local/httpd/conf/
[root@test1 test]# touch /var/local/httpd/conf/passwd
[root@test1 test]# htpasswd -c /usr/local/httpd/conf/passwd 123
New password:
Re-type new password:
Adding password for user 123
#验证
[root@test2 ~]# curl -user=123 www.test.com
Enter host password for user 'ser=123':
This is a test of test!
wget
启动:
-b :转入后台
日志和输出文件:
-o file :将日志信息写入file文件
-a file :追加
-q