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访问。
第一小题:
[root@server ~]# yum install httpd -y
[root@server ~]# yum install mod_ssl -y
[root@server ~]# vim /etc/hosts
编辑配置文件,添加192.168.203.128 www.openlab.com
[root@server ~]# vim /etc/httpd/conf.d/hhh.conf
<VirtualHost 192.168.203.128:80>
Servername www.openlab.com
DocumentRoot /www/openlab
</VirtualHost>
<Directory /www/>
AllowOverride none
Require all granted
</Directory>
[root@server ~]# echo "welcome to openlab" > /www/openlab/index.html
第二小题:
[root@server ~]# mkdir -pv /www/openlab/{student,data,money}
mkdir: 已创建目录 '/www'
mkdir: 已创建目录 '/www/openlab'
mkdir: 已创建目录 '/www/openlab/student'
mkdir: 已创建目录 '/www/openlab/data'
mkdir: 已创建目录 '/www/openlab/money'
[root@server ~]# echo "学生信息" > /www/openlab/student/index.html
[root@server ~]# echo "教学资料" > /www/openlab/data/index.html
[root@server ~]# echo "缴费网站" > /www/openlab/money/index.html
第三小题:
创建用户:[root@server ~]# htpasswd -c /etc/httpd/username song
New password: #123456
Re-type new password:
Adding password for user song
[root@server ~]# htpasswd -c /etc/httpd/username tian
New password: #654321
Re-type new password:
Adding password for user tian
[root@server ~]# htpasswd -c /etc/httpd/username wsy
New password: #111
Re-type new password:
Adding password for user wsy
[root@server ~]# vim /etx/httpd/conf.d/httpds.conf
<Directory /www/openlab/student>
AllowOverride none
AuthType Basic
AuthName "Please Login..."
AuthUserfile /etc/httpd/users
Require user song tian
</Directory>
[root@server ~]# openssl req -utf8 -new -keyout /etc/pki/tls/private/openlab.key -x509 -days 365 -out /etc/pki/tls/certs/openlab.crt
Country Name (2 letter code) [XX]:86
State or Province Name (full name) []:guangdong
Locality Name (eg, city) [Default City]:jieyang
Organization Name (eg, company) [Default Company Ltd]:openlab
Organizational Unit Name (eg, section) []:RHCE
Common Name (eg, your name or your server's hostname) []:server
Email Address []:andy@qq.com
[root@server ~]# vim /etc/httpd/conf.d/httpd.conf
<VirtualHost 192.168.203.128:80>
Servername www.openlab.com
DocumentRoot /www/openlab
Alias /student /root/student
Alias /data /root/data
</VirtualHost>
<Directory /www/>
AllowOverride none
Require all granted
</Directory>
<Directory /root/data>
AllowOverride none
Require all granted
</Directory>
<Directory /root/money>
AllowOverride none
Require all granted
</Directory>
<Directory /root/student>
AllowOverride none
AuthType Basic
AuthName "Please Login..."
AuthUserfile /etc/httpd/users
Require user song tian
</Directory>
<VirtualHost 192.168.203.128:443>
ServerName www.openlab.com
DocumentRoot /www/openlab
Alias /money /root/money
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/localhost.crt
SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
</VirtualHost>
[root@server ~]# systemctl restart httpd
🔐 Enter TLS private key passphrase for www.openlab.com:443 (RSA) : ******