综合练习:请给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访问

 

关闭防火墙和seLinux

HTTP搭建web网站

启用ssl

[[email protected] ~]# cd /etc/pki/tls/certs/

[[email protected] certs]# mkak haha.crt

HTTP搭建web网站

主配置文件

[[email protected] certs]# vim /etc/httpd/conf.d/vhost.conf

<Directory /openlab>

        AllowOverride none

        Require all granted

</Directory>

<Directory /openlab/student>

        AuthType Basic       认证类型

        AuthName "xueshengxinxi"       提示信息

        AuthUserfile /etc/httpd/userfile        认证用户名和密码存放位置

        Require user song tian                需要通过认证的用户名

</Directory>

<VirtualHost 192.168.121.128:443>

        DocumentRoot /openlab                根目录

        alias /money /openlab/money           别名

        ServerName www.openlab.com           服务名称

        SSLEngine on              引擎打开

        SSLProtocol all -SSLv2       支持协议处理SSLv2

        SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA  密码套件客户端和服务端

        SSLCertificateFile /etc/pki/tls/certs/haha.crt          证书路径

        SSLCertificateKeyFile /etc/pki/tls/certs/haha.key      **路径

        ErrorLog "/var/log/httpd/dummy-host2.example.com-error_log"  错误日志存放地址

        CustomLog "/var/log/httpd/dummy-host2.example.com-access_log" common

</VirtualHost>

<VirtualHost 192.168.121.128:80>

        ServerName www.openlab.com

        DocumentRoot /openlab

</VirtualHost>

 

将域名导入hosts文件中去

HTTP搭建web网站

注:Windows文件在  C/windows/System32/drivers/etc/hosts

HTTP搭建web网站

创建用户:song和tian

注:第一次创建时需要-c,后面不需要

[[email protected] certs]# htpasswd -c /etc/httpd/userfile song    创建用户注:第一次创建时需要-c,后面不需要

New password:

Re-type new password:

Adding password for user song

[[email protected] certs]# htpasswd /etc/httpd/userfile tian

New password:

Re-type new password:

Adding password for user tian

 

新建目录:

[[email protected] certs]# mkdir /openlab -pv

[[email protected] certs]# mkdir /openlab/money

[[email protected] certs]# mkdir /openlab/data

[[email protected] certs]# mkdir /openlab/student

 

写网页信息:

HTTP搭建web网站

重启httpd服务:

systemctl  restart  httpd

 

结果:

访问主页

HTTP搭建web网站

访问student页面

输入用户和密码

HTTP搭建web网站

成功进入

HTTP搭建web网站

访问data页面

HTTP搭建web网站

 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-22
  • 2021-10-14
  • 2021-05-29
  • 2021-11-09
  • 2021-09-09
  • 2021-11-01
猜你喜欢
  • 2021-05-30
  • 2021-11-22
  • 2022-12-23
  • 2021-04-02
  • 2022-01-15
  • 2021-08-02
  • 2021-09-27
相关资源
相似解决方案