作业:请给openlab搭建web网站
网站需求:
1.基于域名 www.openlab.com 可以访问网站内容为 welcome to openlab!!!
2.给该公司创建三个子界面分别显示学生信息,教学资料和缴费网站,
1、基于 www.openlab.com/student 网站访问学生信息,
2、基于 www.openlab.com/data 网站访问教学资料
3、基于 www.openlab.com/money 网站访问缴费网站。
3.要求
(1)学生信息网站只有 song 和 tian 两个用户可以访问,其他用户不能访问。
(2)访问缴费网站实现数据加密基于 https 访问。
1..基于域名 www.openlab.com 可以访问网站内容为 welcome to openlab!!!
下载httpd协议
dnf install httpd
xi
写本地解析
192.168.203.137 写自己的IP地址
[root@localhost conf.d]# mkdir /www/zuoye -p
[root@localhost conf.d]# echo "welcome to openlab "\!\!\!"" > /www/zuoye/index.html
[root@localhost conf.d]# systemctl restart httpd
[root@localhost conf.d]#setenforce 0
2.
2.给该公司创建三个子界面分别显示学生信息,教学资料和缴费网站,
1、基于 www.openlab.com/student 网站访问学生信息,
2、基于 www.openlab.com/data 网站访问教学资料
3、基于 www.openlab.com/money 网站访问缴费网站。
[root@localhost conf.d]# vim host.conf
[root@localhost conf.d]# mkdir /www/zuoye/student
[root@localhost conf.d]# mkdir /www/zuoye/data
[root@localhost conf.d]# mkdir /www/zuoye/money
[root@localhost conf.d]# echo "This is student " > /www/zuoye/student/index.html
[root@localhost conf.d]# echo "This is data " > /www/zuoye/data/index.html
[root@localhost conf.d]# echo "This is money " > /www/zuoye/money/index.html
[root@localhost conf.d]# vim /etc/hosts
[root@localhost conf.d]# systemctl restart httpd
host.conf配置文件
<directory /www>allowoverride nonerequire all granted
</directory>
<virtualhost 192.168.203.137:80>ServerName www.openlab.comdocumentroot /www/zuoye
</virtualhost>
<virtualhost 192.168.203.137:80>ServerName www.openlab.comdocumentroot /www/zuoyeAlias /student /www/zuoye/student
</virtualhost>
<virtualhost 192.168.203.137:80>Servername www.openlab.comdocumentroot /www/zuoyeAlias /data /www/zuoye/data
</virtualhost>
<virtualhost 192.1688.203.137:80>Servername www.openlab.comdocumentroot /www/zuoyeAlias /money /www/zuoye/money
</virtualhost>
hosts文件
3..要求
(1)学生信息网站只有 song 和 tian 两个用户可以访问,其他用户不能访问。
(2)访问缴费网站实现数据加密基于 https 访问。
[root@localhost conf.d]# dnf install mod_ssl
[root@localhost conf.d]# vim /etc/httpd/conf.d/ssl.conf
[root@localhost conf.d]# yum install mod_ssl httpd - y
[root@localhost conf.d]# cd /etc/pki/tls/certs/
[root@localhost certs]# openssl genrsa - aes128 2048 > jiami.key
[root@localhost certs]# openssl req -utf8 -new -key jiami.key -x509 -days 100 -out jiami.crt
[root@localhost certs]# vim /etc/httpd/conf.d/host.conf
[root@localhost certs]# firewall-cmd --permanent --add-port=443/tcp
[root@localhost certs]# systemctl restart httpd
vim /etc/httpd/conf.d/ssl.conf
写自己配的域名
下图也要写自己配置的域名
vim /etc/httpd/conf.d/host.conf
<directory /www>allowoverride nonerequire all granted
</directory>
<virtualhost 192.168.203.137:80>ServerName www.openlab.comdocumentroot /www/zuoye
</virtualhost>
<virtualhost 192.168.203.137:80>ServerName www.openlab.comdocumentroot /www/zuoyeAlias /student /www/zuoye/student
</virtualhost>
<virtualhost 192.168.203.137:80>Servername www.openlab.comdocumentroot /www/zuoyeAlias /data /www/zuoye/data
</virtualhost>
<virtualhost 192.168.203.137:443>Servername www.openlab.comdocumentroot /www/zuoyeAlias /money /www/zuoye/moneySSLEngine onSSLCertificateFile /etc/pki/tls/certs/localhost.crtSSLCertificateKeyFile /etc/pki/tls/private/localhost.key
</virtualhost>~
~
[root@localhost conf.d]# htpasswd -c /etc/httpd/zhanghao song
[root@localhost conf.d]# htpasswd /etc/httpd/zhanghao tian
[root@localhost conf.d]# vim /etc/httpd/conf.d/host.conf
[root@localhost conf.d]# systemctl restart httpd
[root@localhost conf.d]# curl -k https://www.openlab.com/student/ -u tian
Enter host password for user 'tian':
This is student
host.conf的文件
<directory /www>allowoverride nonerequire all granted
</directory>
<virtualhost 192.168.203.137:80>ServerName www.openlab.comdocumentroot /www/zuoye
</virtualhost>
<virtualhost 192.168.203.137:80>ServerName www.openlab.comdocumentroot /www/zuoyeAlias /student /www/zuoye/student
</virtualhost>
<directory /www/zuoye/student>
authtype basic
authname "This is a private directory,Please Login: "
authuserfile /etc/httpd/zhanghao
require user song tian
</directory>
<virtualhost 192.168.203.137:80>Servername www.openlab.comdocumentroot /www/zuoyeAlias /data /www/zuoye/data
</virtualhost>
<virtualhost 192.168.203.137:443>Servername www.openlab.comdocumentroot /www/zuoyeAlias /money /www/zuoye/moneySSLEngine onSSLCertificateFile /etc/pki/tls/certs/localhost.crtSSLCertificateKeyFile /etc/pki/tls/private/localhost.key
</virtualhost>~