Engineer-Exec06-参考解析

案例1:为虚拟机 server 配置以下虚拟Web主机

  • 实现三个网站的部署
  • 实现客户端访问server0.example.com网页内容为 大圣归来
  • 实现客户端访问www0.example.com网页内容为 大圣又归来
  • 实现客户端访问webapp0.example.com网页内容为 大圣累了
    [root@server0 ~]# yum -y install httpd
    [root@server0 ~]# cd /var/www
    [root@server0 www]# mkdir lss01 lss02 lss03
    [root@server0 www]# echo ‘

    大圣归来’ > lss01/index.html
    [root@server0 www]# echo ‘

    大圣又归来’ > lss02/index.html
    [root@server0 www]# echo ‘

    大圣累了’ > lss03/index.html
    [root@server0 www]# vim /etc/httpd/conf.d/shlss.conf
    <VirtualHost *:80>
    ServerName server0.example.com
    DocumentRoot /var/www/lss01

    <VirtualHost *:80>
    ServerName www0.example.com
    DocumentRoot /var/www/lss02

    <VirtualHost *:80>
    ServerName webapp0.example.com
    DocumentRoot /var/www/lss03

    [root@server0 www]# firewall-cmd --set-default-zone=trusted
    [root@server0 www]# systemctl restart httpd

案例2:为虚拟机 server 配置Web访问控制
在 Web 网站 http://server0.example.com 的 DocumentRoot 目录下创建一个名为 private 的子目录,要求如下:
1)在server0.example.com的DocumentRoot目录下,private的子目录里书写网页文件index.html内容为 大圣偷偷归来
2)此页面只能在本机浏览,但是从其他系统不能访问这个目录的内容
[root@server0 www]# mkdir /var/www/lss01/private
[root@server0 www]# echo ‘

大圣偷偷归来’ > /var/www/lss01/private/index.html
[root@server0 www]# vim /etc/httpd/conf.d/shlss01.conf
[root@server0 www]# systemctl restart httpd

案例3:为虚拟机 server 使用自定Web根目录(保证SELinux为开启状态)

调整 Web 站点 http://server0.example.com 的网页目录,要求如下:
1)新建目录 /webroot,作为此站点新的网页目录
2)确保站点 http://server0.example.com 仍然可访问
[root@server0 www]# mkdir /webroot
[root@server0 www]# echo ‘

我勒个去’ > /webroot/index.html
[root@server0 www]# vim /etc/httpd/conf.d/shlss.conf
<VirtualHost *:80>
ServerName server0.example.com
DocumentRoot /webroot

[root@server0 ~]# chcon -R --reference=/var/www /webroot
[root@server0 ~]# cp /var/www/lss01/private/index.html /webroot/
[root@server0 ~]#vim /etc/httpd/conf.d/shlss01.conf
<Directory “/webroot”>
Require all granted

[root@server0 ~]# systemctl restart httpd

案例4:为虚拟机 server 部署动态WSGI站点
为站点 webapp0.example.com 配置提供动态Web内容,要求如下:
1)此虚拟主机侦听在端口8909
2)测试网页从以下地址下载,不要作任何更改http://classroom/pub/materials/webinfo.wsgi
3)从浏览器访问 http://webapp0.example.com:8909 可接收到动态生成的 Web 页面

案例5:配置安全Web服务
为站点 https://www0.example.com 配置TLS加密
1)一个已签名证书从以下地址获取 http://classroom/pub/tls/certs/server0.crt
2)此证书的密钥从以下地址获取 http://classroom/pub/tls/private/server0.key
3)根证书的签名授权信息从以下地址获取 http://classroom/pub/example-ca.crt

指定网站证书
100 SSLCertificateFile /etc/pki/tls/certs/server0.crt
指定解密的私钥
107 SSLCertificateKeyFile /etc/pki/tls/private/server0.key
指定根证书
122 SSLCACertificateFile /etc/pki/tls/certs/example-ca.crt
[root@server0 /]# systemctl restart httpd

发布了55 篇原创文章 · 获赞 0 · 访问量 428

猜你喜欢

转载自blog.csdn.net/weixin_45533230/article/details/103716064