一.基于域名www.openlab.com可以访问网站内容为 welcome to openlab!!!
1.关闭selinux及防火墙然后安装httpd
2.在Windows中找到C:\Windows\System32\drivers\etc下hosts文件记事本打开
定位最后一行,输入以下内容 192.168.125.128 www.openlab.com
[root@server ~]# vim /etc/hosts
3.创建文件并将所需内容填入到对应目录中并关闭防火墙和selinux
[root@server ~]# echo welcome to openlab ! > /www/openlab/index.html
[root@server ~]# systemctl stop firewalld
[root@server ~]# setenforce 0
结果如下:
二.给该公司创建三个子界面分别显示学生信息,教学资料和缴费网站,基于www.openlab.com/student 网站访问学生信息,www.openlab.com/data网站访问教学资料www.openlab.com/money 网站访问缴费网站
1.创建三个目录,并在对应的index.html写入内容
[root@server ~]# mkdir /www/openlab/student
[root@server ~]# mkdir /www/openlab/data
[root@server ~]# mkdir /www/openlab/money
[root@server ~]# echo student > /www/openlab/student/index.html
[root@server ~]# echo data > /www/openlab/data/index.html
[root@server ~]# echo money > /www/openlab/money/index.html
[root@server ~]# cat /www/openlab/student/index.html
2.创建两个用户tian和song
[root@server ~]# htpasswd -c /etc/httpd/user song
New password:
Re-type new password:
Adding password for user song
[root@server ~]# htpasswd /etc/httpd/user tian
New password:
Re-type new password:
Adding password for user tian
3.修改用户配置文件
[root@server ~]# vim /etc/httpd/conf.d/userdir.conf
结果如下:
三.要求
(1) 学生信息网站只有song和tian两人可以访问,其他用户不能访问。
(2) 访问缴费网站实现数据加密基于https访问。
1.安装mod_ssl插件
[root@server ~]# yum install mod_ssl
2.在/etc/pki/tls/private 目录下生成私钥文件
[root@server ~]# cd /etc/pki/tls/private/
[root@server private]# ll
总用量 0
[root@server private]# openssl genrsa -aes128 2048 > money.key
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:
在/etc/pki/tls/certs目录下新建证书
[root@server private]# cd /etc/pki/tls/certs/
[root@server certs]# openssl req -utf8 -new -key /etc/pki/tls/private/money.key -x509 -days 365 -out money.crt
Enter pass phrase for /etc/pki/tls/private/money.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) []:shanxi
Locality Name (eg, city) [Default City]:xi'an
Organization Name (eg, company) [Default Company Ltd]:openlab
Organizational Unit Name (eg, section) []:RHCE
Common Name (eg, your name or your server's hostname) []:localhost
Email Address []:money@qq.com
输入证书信息时,必须一次性写对,不能退格删除
3.主配置文件的编辑
/etc/httpd/conf.d/ssl.conf在结尾添加以下内容
<VirtualHost 192.168.38.128:443>
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/money.crt
SSLCertificateKeyFile /etc/pki/tls/private/money.key
ServerName www.openlab.com
DocumentRoot /www/openlab/money
</VirtualHost>
<Directory /www/openlab/money>
AllowOverride none
Require all granted
</Directory>
4.重启http服务
[root@server conf.d]# systemctl restart httpd
结果如下:
5.鼠标点击高级选项