第二次作业
综合练习:请给openlab搭建web网站
网站需求:
1.基于域名[www.openlab.com](http://www.openlab.com)可以访问网站内容为 welcome to openlab!!!
- 更改配置文件
[root@xixi ~]# vim /etc/httpd/conf.d/vhosts.conf
- 创建openlab文件
[root@xixi ~]# mkdir /var/www/openlab
- 把 welcome to openlab!!! 写入文件
[root@xixi ~]# echo 'welcome to openlab !!!' > /www/openlab/index.html
- 重启hppd服务
[root@xixi ~]## systemctl restart httpd
- 写域名解析
[root@xixi ~]# vim /etc/hosts
- 关闭防火墙
[root@xixi ~]# setenforce 0
- 用curl测试:[root@xixi ~]# curl http://www.openlab.com
2.给该公司创建三个子界面分别显示学生信息,教学资料和缴费网站,基于[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网站访问缴费网站) 。
创建 data文件,并写入内容。
[root@xixi ~]# mkdir /www/openlab/data
[root@xixi ~]# echo this is data > /www/openlab/data/index.html ---写入内容
[root@xixi ~]# curl http://www.openlab.com/data/ ---通过curl 访问一下
this is data
【Curl http://www.openlab.com/data 访问网页文件书写
Curl http://www.openlab.com/data/ 访问目录文件书写,后面多了“/”】
[root@xixi ~]# mkdir /www/openlab/student
[root@xixi ~]# echo this is student > /www/openlab/student/index.htlm
更改配置文件
[root@xixi ~]# vim /etc/httpd/conf.d/vhosts.conf
重启httpd服务
[root@xixi ~]# systemctl restart httpd
curl测试一下
[root@xixi ~]# curl -k http://www.openlab.com/student/ -u song:123
this is student
[root@xixi ~]# curl -k http://www.openlab.com/student/ -u song:123
this is student
3.要求
(1)学生信息网站只有song和tian两人可以访问,其他用户不能访问。
(2)访问缴费网站实现数据加密基于https访问。
添加song,tian 用户信息,指定用户名及密码
[root@xixi ~]# htpasswd -c /etc/httpd/users song
New password:
Re-type new password:
Adding password for user song
[root@xixi ~]# htpasswd /etc/httpd/users tian
New password:
Re-type new password:
Adding password for user tian
査看需要的用户是否添加
下载mod_ssl软件
[root@xixi ~]# yum install mod_ssl -y
创建certs和money目录,并给money写入内容
[root@xixi ~]# mkdir /www/certs
[root@xixi ~]# mkdir /www/certs/money
[root@xixi ~]# echo this is money > /www/certs/money/index.html
[root@xixi ~]# cat /www/certs/money/index.html
this is money
再一次重启httpd服务
[root@xixi ~]# systemctl restart httpd
制作秘钥及证书
[root@xixi ~]# mkdir /certs
[root@xixi ~]# mkdir /private
[root@xixi ~]# openssl genrsa 2048 > /private/haha.key
[root@xixi ~]# openssl req -new -key haha.key -x509 -days 365 -out /certs/haha.crt
curl测试一下
[root@xixi ~]# curl -k http://www.openlab.com/student/ -u song:123
this is student
[root@xixi ~]# curl -k http://www.openlab.com/student/ -u tian:456
this is student
[root@xixi ~]# curl -k https://www.openlab.com/money/
this is money