1.基于域名www.openlab.com可以访问网站内容为 welcome to openlab!!! 2.给该公司创建三个子界面分别显示学生信息,教学资料和缴费网站,基于www.openlab.com/student 网站访问学生信息,www.openlab.com/data网站访问教学资料 www.openlab.com/money网站访问缴费网站。 3.要求 :(1)学生信息网站只有song和tian两人可以访问,其他用户不能访问。 ? ? ? ? ? ? ? ?(2)访问缴费网站实现数据加密基于https访问
1.基于域名www.openlab.com可以访问网站内容为 welcome to openlab!!!
(1)制作服务器证书
[root@localhost fff]# openssl req -newkey rsa ?-nodes -keyout openlab.key -x509 -days 365 -out openlab.crt Generating a RSA private key ......................................................................................................................+++++ ..+++++ writing new private key to 'openlab.key' ----- You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [XX]:86 State or Province Name (full name) []:ningxia Locality Name (eg, city) [Default City]:yinchuan Organization Name (eg, company) [Default Company Ltd]:openlab Organizational Unit Name (eg, section) []:1? Common Name (eg, your name or your server's hostname) []:localhost Email Address []:2674556937@qq.com
(2)先定义基于域名访问的网站配置文件 ,然后创建测试网页文件根目录,定义网页内容,最后重启服务
[root@localhost openlab]# vim /etc/httpd/conf.d/vhosts.conf?
[root@localhost openlab]# cat /etc/httpd/conf.d/vhosts.conf?
<VirtualHost ?192.168.138.135:443>
? ? ServerName ? ? www.openlab.com?
? ? DocumentRoot ? ? ? /www/openlab ?
? ? SSLEngine on
? ??SSLCertificateFile /etc/pki/tls/certs/openlab.crt
? ? SSLCertificateKeyFile /etc/pki/tls/private/openlab.key
</VirtualHost>
<Directory ? /www>
? ? AllowOverride none
? ? Require all granted
</Directory>
[root@localhost openlab]# mkdir -pv /www/openlab
[root@localhost openlab]# echo 这是一个https测试文件 > /www/openlab/index.html
[root@localhost openlab]# echo welcome to openlab!! >> /www/openlab/index.html
echo welcome to openlabcat /etc/httpd/conf.d/vhosts.conf ?>> /www/openlab/index.html
[root@localhost fff]# vim /etc/hosts
[root@localhost fff]# cat /etc/hosts
127.0.0.1 ? localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 ? ? ? ? localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.138.135 www.openlab.com
[root@localhost openlab]# systemctl restart httpd
2.给该公司创建三个子界面分别显示学生信息,教学资料和缴费网站,
<VirtualHost ?192.168.138.135:443>
? ? ? ? ServerName ? ? wwww.openlab.com
? ? ? ? DocumentRoot ? ? ? /www/openlab
? ? ? ? Alias /student ? /ce1
? ? ? ? Alias /date ? ? ?/ce2
? ? ? ? Alias /money ? ?/ce3
? ? ? ? SSLEngine on
? ? ? ? SSLCertificateFile /etc/pki/tls/certs/openlab.crt
? ? ? ? SSLCertificateKeyFile /etc/pki/tls/private/openlab.key
</VirtualHost> ?
[root@localhost /]# mkdir -pv ce1
mkdir: 已创建目录 'ce1'
[root@localhost /]# mkdir -pv ce2
mkdir: 已创建目录 'ce2'
[root@localhost /]# mkdir -pv ce3
mkdir: 已创建目录 'ce3'
[root@localhost /]# echo 学生信息 > /ce1/index.html
[root@localhost /]# echo 教学资料 ?> /ce2/index.html
[root@localhost /]# echo 缴费网站 ?> /ce3/index.html
3.(1)学生信息网站只有song和tian两人可以访问,其他用户不能访问。
在学生信息网站的目录下进行配置
?vim /etc/httpd/conf.d/vhosts.conf
<Directory ? /ce1>
? ? ? ? AllowOverride none
? ? ? ? AuthType basic
? ? ? ? AuthName "login"
? ? ? ? AuthUserfile /etc/httpd/users
? ? ? ? Require user song
? ? ? ? Require user tian
</Directory> ?
[root@localhost /]# htpasswd ?-c ?/etc/httpd/users tian
New password:?
Re-type new password:?
Adding password for user tian
[root@localhost /]# htpasswd ? ?/etc/httpd/users song
New password:?
Re-type new password:?
Adding password for user song
[root@localhost /]# cat /etc/httpd/users
tian:$apr1$7IBNs..3$SK/qV7wm/QZ/Tbj7NBgRs0
song:$apr1$BQQo.P6j$OktS6H0XaCbw23cGr5xIn/
|