RHCE再练手-1

1.基于域名访问网站内容

# yum install httpd //装httpd包
# mkdir /openlab/
# vim /etc/httpd/conf.d/openlab.conf //新建一个配置文件
-------------------------------------------openlab.conf配置内容
<virtualhost 192.168.155.28>
        documentroot /openlab/
        servername 192.168.155.28
        serveralias www.openlab.com
        ErrorLog "/var/log/httpd/openlab.example.com-error_log"
        CustomLog "/var/log/httpd/openlab.example.com-access_log" common

</virtualhost>
<directory /openlab/>
        allowoverride none
        require all granted
</directory>
----------------------------------------------
# setenforce 0 //临时关闭selinux
# systemctl stop firewalld //关闭防火墙
#systemctl restart httpd //重启服务

Windows操作:(在不配置DNS服务器情况下简易的IP域名匹配操作)

C:\Windows\System32\drivers\hosts //自定义IP域名匹配
192.168.155.28 www.openlab.com

在这里插入图片描述

2. 接着上面所有操作,创建网页三个子目录

[root@rhel1 /]# cd openlab/

[root@rhel1 openlab]# mkdir data
[root@rhel1 openlab]# mkdir money
[root@rhel1 openlab]# mkdir student

[root@rhel1 ~]# echo student > /openlab/student/index.html
[root@rhel1 ~]# echo money > /openlab/money/index.html
[root@rhel1 ~]# echo data > /openlab/data/index.html

# vim /etc/httpd/conf.d/openlab.conf 
------------------------------------------------openlab.conf配置内容
<virtualhost 192.168.155.28>
        documentroot /openlab/
        servername 192.168.155.28
        serveralias www.openlab.com
        alias /data /openlab/data/
        alias /money /openlab/money/
        alias /student /openlab/student

        ErrorLog "/var/log/httpd/openlab.example.com-error_log"
        CustomLog "/var/log/httpd/openlab.example.com-access_log" common

</virtualhost>

<directory /openlab/>
        allowoverride none
        require all granted
</directory>
-------------------------------------------------------------
#systemctl restart httpd //重启httpd服务

在这里插入图片描述

3. 接着上面所有操作,对/money子页面 限定网络账号访问 并且启动安全套接层实现https访问

#yum install mod_ssl //安装ssl包
[root@rhel1 openlab]# cd /etc/pki/tls/certs/
[root@rhel1 certs]# /usr/bin/openssl genrsa -aes128 2048 > money.key

Generating RSA private key, 2048 bit long modulus (2 primes)
.+++++
......................................................................................+++++
e is 65537 (0x010001)

Enter pass phrase:				//自定义新密码,不填则为空
Verifying - Enter pass phrase:   //确认密码,不填则确认为空

[root@rhel1 certs]# openssl req -utf8 -new -key money.key -x509 -days 365 -out moneyzhengshu.crt -set_serial 0


#vim /etc/httpd/conf.d/openlab.conf
----------------------------------------------openlab.conf
<virtualhost 192.168.155.28>
        documentroot /openlab/
        servername 192.168.155.28
        serveralias www.openlab.com
        alias /data /openlab/data/
        alias /money /openlab/money/
        alias /student /openlab/student/
  
             
        SSLengine on	//启用安全套接层
        SSLcertificatefile /etc/pki/tls/certs/moneyzhengshu.crt
        SSLcertificatekeyfile /etc/pki/tls/certs/money.key
        
        ErrorLog "/var/log/httpd/openlab.example.com-error_log"
        CustomLog "/var/log/httpd/openlab.example.com-access_log" common
</virtualhost>

<directory /openlab/>
        allowoverride none
        require all granted
</directory>

<directory /openlab/student/>
        allowoverride none
        authtype basic
        authname "ID please?"
        authuserfile /etc/httpd/mima/song
        Require user song
</directory>

<directory /openlab/money/>
        allowoverride none
        authtype basic
        authname "ID please?"
        authuserfile /etc/httpd/mima/tian
        Require user tian    
</directory>
------------------------------------------------------------
#systemctl restart httpd //重启httpd服务

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值