1.关闭防火墙
[root@server ~]# setenforce 0
[root@server ~]# systemctl stop firewalld
2.安装httpd服务
[root@server ~]# yum install httpd mod_ssl -y
3.新建网页目录
[root@server /]# mkdir -p /www/opanlab
4.修改/etc/hosts的映射(使其可以域名访问)
[root@server /]# vim /etc/hosts
192.168.136.133 www.openlab.com
5.给网站主页写入内容
[root@server ~]# echon "openlab欢迎你的加入" > /www/openlab/index.html
6.编辑配置文件
<VirtualHost 192.168.136.133>
DocumentRoot /www/openlab
ServerName "www.opanlab.com"
<Directory /www/openlab>
AllowOverride None
require all granted
</Directory>
</virtualHost>
7.重启服务
[root@server ~]# systemctl restart httpd
二、创建教学资料网站
[root@server /]# mkdir -p /www/openlab/data
[root@server /]# echo '资料下载' > /www/openlab/data/index.html
[root@server /]# vim /etc/httpd/conf/httpd.conf
[root@server /]# systemctl restart httpd
<Virtualhost 192.168.136.133>
DocumentRoot /www/openlab/data
alias /data /www/openlab/data
Servername "www.openlab.com"
</virtualhost>
<Directory /www/openlab/data>
allowoverride none
require all granted
</Directory>
重启服务
三、创建学生网站
[root@server ~]# mkdir -p /www/openlab/student
[root@server ~]# vim /etc/httpd/conf/httpd.conf
[root@server ~]# echo 'student' > /www/openlab/student/index.html
[root@server ~]# useradd song
[root@server ~]# passwd song
[root@server ~]# useradd tian
[root@server ~]# passwd tian
[root@server ~]# htpasswd -c /etc/httpd/passwd song
[root@server ~]# htpasswd /etc/httpd/passwd tian
[root@server ~]# vim /etc/httpd/conf/httpd.conf
<Directory /www/openlab/student>
authuserfile /etc/httpd/passwd
authname "student"
authtype basic
require user tian song
</directory>
四、创建缴费网站
[root@server ~]# vim /etc/httpd/conf/httpd.conf
[root@server ~]# mkdir /www/openlab/money
[root@server ~]# echo 'money' > /www/openlab/money/index.html
[root@server ~]# vim /etc/httpd/conf/httpd.conf
[root@server ~]# systemctl restart httpd