综合练习:请给openlab搭建web网站网站需求:
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访问。
挂载
配置yum文件
[root@localhost ~]# vim /etc/yum.repos.d/base.repo
[base]name=base
baseurl=file:///mnt
gpgcheck=0
enable=1
安装httph和ssl模块
[root@localhost ~]# yum install -y httpd
[root@localhost ~]# yum install -y mod_ssl
关闭防火墙和selinux
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0启动http服务
[root@localhost ~]# systemctl start httpd修改主配置文件
[root@localhost ~]# vim /etc/httpd/conf/httpd.confServerName 0.0.0.0:80添加证书
[root@localhost ~]# cd /etc/pki/tls/certs/
[root@localhost certs]# make haha.crt配置主配置文件[root@localhost certs]# vim /etc/httpd/conf.d/vhosts.conf
<Directory /openlab>
AllowOverride none
Require all granted
<Directory /openlab/student>
AuthType Basic
AuthName “please login:”
AuthUserfile /etc/httpd/yonghu<VirtualHost 192.168.246.132:443>
SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA
SSLCertificateFile /etc/pki/tls/certs/haha.crt
SSLCertificateKeyFile /etc/pki/tls/certs/haha.key
DocumentRoot /openlab/money
ServerName www.openlab.com
Alias /money /openlab/money
ErrorLog “/var/log/httpd/dummy-host2.example.com-error_log”
CustomLog “/var/log/httpd/dummy-host2.example.com-access_log” common
<VirtualHost 192.168.246.132:80>
DocumentRoot /openlab
ServerName www.openlab.com
ErrorLog “/var/log/httpd/dummy-host2.example.com-error_log”
CustomLog “/var/log/httpd/dummy-host2.example.com-access_log” common
重启http
[root@localhost certs]# systemctl restart httpd
创建目录
[root@localhost certs]#
mkdir /openlab/{student,money,date} -pvmkdir: 已创建目录 “/openlab”
mkdir: 已创建目录 “/openlab/student”
mkdir: 已创建目录 “/openlab/money”
mkdir: 已创建目录 “/openlab/date”
[root@localhost certs]# echo ‘welcome to openlab!!!’ > /openlab/index.html
[root@localhost certs]# echo xueshengxinxi > /openlab/studedt/index.html
[root@localhost certs]# echo jiaoxueziliao > /openlab/date/index.html
[root@localhost certs]# echo jiaofeiwangzhan > /openlab/money/index.html创建用户
[root@localhost ~]# htpasswd -c /etc/httpd/yonghu songNew password: Re-type new password: Adding password for user song
[root@localhost ~]# htpasswd /etc/httpd/yonghu tian
New password:
Re-type new password:
Adding password for user tian修改本地hosts文件
[root@localhost certs]# vim /etc/hosts
192.168.246.132 www.openlab.com
测试