基于域名[www.openlab.com](http://www.openlab.com)可以访问网站内容为 welcome to openlab!!!
安装服务器软件
dnf install -y httpd
更改配置文件
vim /etc/hosts
192.168.17.130 www.openlab.com
创建目录,并在创建文件下写入welcome to openlabll !!!
mkdir -p /www/openlab
ls /www
echo "welcome to openlab!!!" > /www/openlab/index.html
cat /www/openlab/index.html
修改网页的配置文件
vim /etc/httpd/conf.d/openlab.conf
<VirtualHost 192.168.17.130:80>
DocumentRoot /www/openlab
ServerName www.openlab.com
ErrorLog "/var/log/httpd/130-error_log"
CustomLog "/var/log/httpd/130-access_log" common
</VirtualHost>
<directory /www/openlab>
AllowOverride None
Require all granted
</directory>
~
关闭防火墙以及setenforce源
systemctl stop firewalld
setenforce 0
重启hppd服务
systemctl restart httpd
访问验证
curl www.openlab.com
给该公司创建三个子界面分别显示学生信息,
教学资料和缴费网站,基于[www.openlab.com/student](http://www.openlab.com/student)
网站访问学生信息,[www.openlab.com/data](http://www.openlab.com/data)
网站访问教学资料[www.openlab.com/money网站访问缴费网站](http://www.openlab.com/money网站访问缴费网站)。
创建子界面目录
mkdir /www/openlab/{student,data,money}
echo "学生信息" > /www/openlab/student/index.html
echo "教学资料" > /www/openlab/data/index.html
echo "缴费网站" > /www/openlab/money/index.html
修改配置文件
vim /etc/httpd/conf.d/openlab.conf
<VirtualHost 192.168.26.130:80>
DocumentRoot /www/openlab/student
ServerName www.openlab.com/student
ErrorLog "/var/log/httpd/student-error_log"
CustomLog "/var/log/httpd/student-access_log" common
</VirtualHost>
<VirtualHost 192.168.26.130:80>
DocumentRoot /www/openlab/data
ServerName www.openlab.com/data
ErrorLog "/var/log/httpd/data-error_log"
CustomLog "/var/log/httpd/data-access_log" common
</VirtualHost>
<VirtualHost 192.168.26.130:80>
DocumentRoot /www/openlab/money
ServerName www.openlab.com/money
ErrorLog "/var/log/httpd/money-error_log"
CustomLog "/var/log/httpd/money-access_log" common
</VirtualHost>
重启hppd服务
systemctl restart httpd
测试能否访问成功
curl www.openlab.com/student/
curl www.openlab.com/data/
curl www.openlab.com/money/
要求
(1)学生信息网站只有song和tian两人可以访问,其他用户不能访问。
(2)访问缴费网站实现数据加密基于https访问。
首先我们就创建song和tian这两个用户
htpasswd -c /etc/httpd/mymima song
htpasswd /etc/httpd/mymima tian
编辑配置文件修改他们的访问权限
vim /etc/httpd/conf.d/openlab.conf
<directory /www/openlab/student>
AllowOverride None
authtype basic
authname "please login"
authuserfile /etc/httpd/mymima
require user song tian
</directory>
重启
systemctl restart httpd
客户端访问
curl www.openlab.com/student/ -u tian
curl www.openlab.com/student/ -u song
安装mod_ssl
dnf install mod_ssl -y
编辑配置文件修改他们的访问权限
vim /etc/httpd/conf.d/openlab.conf
<virtualhost 192.168.17.130:443>
servername www.openlab.com
documentroot /www/openlab/money
sslengine on
SSLCertificateFile /etc/pki/tls/certs/openlab.crt
SSLCertificateKeyFile /etc/pki/tls/private/openlab.key
</virtualhost>
<directory /www/openlab/money>
allowoverride none
require all granted
</directory>
重启
systemctl restart httpd