Linux系统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访问。
配置域名www.openlab.com网站
关闭防火墙
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
安装软件包Apache--httpd
[root@localhost ~]# yum install httpd -y
[root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf
<virtualhost 192.168.230.135:80>
ServerName www.openlab.com
DocumentRoot /www
<Directory /www>
AllowOverride none
Require all granted
</Directory>
</Virtualhost>
[root@localhost ~]# mkdir /www
[root@localhost ~]# echo welcome to openlab!!! > /www/index.html
echo welcome to openlabcd ~! > /www/index.html
[root@localhost ~]# systemctl restart httpd
在Linux终端上使用firefox 命令,打开浏览器输入http://www.openlab.com
配置子界面
配置data子界面
[root@localhost ~]# mkdir /www/data
[root@localhost ~]# echo this is data > /www/data/index.html
[root@localhost ~]# systemctl restart httpd
配置student子界面
[root@localhost ~]# mkdir /www/student
[root@localhost ~]# echo this is student > /www/student/index.html
[root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf
<Directory /www/student>
AllowOverride none
AuthType Basic
AuthName "......"
AuthUserFile /etc/httpd/users
Require user song tian
</Directory>
[root@localhost ~]# htpasswd -c /etc/httpd/users song
New password:
Re-type new password:
Adding password for user song
[root@localhost ~]# htpasswd /etc/httpd/users tian
New password:
Re-type new password:
Adding password for user tian
[root@localhost ~]# curl -u song:redhat http://www.openlab.com/student/
this is student
配置money子界面
[root@localhost ~]# yum install mod_ssl -y
[root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf
<virtualhost 192.168.230.135:443>
ServerName www.openlab.com
DocumentRoot /private
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/openlab.crt
SSLCertificateKeyFile /etc/pki/tls/private/openlab.key
<Directory /private>
AllowOverride none
Require all granted
</Directory>
</Virtualhost>
[root@localhost ~]# mkdir /private/money -pv
mkdir: 已创建目录 '/private'
mkdir: 已创建目录 '/private/money'
[root@localhost ~]# echo this is money > /private/money/index.html
[root@localhost ~]# openssl req -newkey rsa:4096 -nodes -sha256 -keyout /etc/pki/tls/certs/openlab.key -x509 -days 365 -out /etc/pki/tls/private/openlab.crt
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:86
State or Province Name (full name) []:shanxi
Locality Name (eg, city) [Default City]:xian
Organization Name (eg, company) [Default Company Ltd]:openlab
Organizational Unit Name (eg, section) []:rhce
Common Name (eg, your name or your server's hostname) []:money
Email Address []:money@money.com