RHCE Day1

一、搭建静态网站
[root@localhost ~]# yum install httpd -y
[root@localhost ~]# systemctl status firewalld
[root@localhost ~]#systemctl stop firewalld
[root@localhost ~]#systemctl disable firewalld
[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# echo hello world > /var/www/html/index.html
[root@localhost ~]# curl 192.168.126.140
hello world

二、建立两个基于ip地址访问的网站,要求如下:
1、该网站ip地址的主机位为100,设置DocumentRoot为/www/ip/100,网页内容为:this is 100。
2、该网站ip地址主机位为200,设置DocumentRoot为/www/ip/200,网页内容为:this is 200。
第一步,先添加两个ip地址
[root@localhost ~]#nmcli connection modify eno16777736 +ipv4.addresses 192.168.126.100/24 ipv4.gateway 192.168.126.1
[root@localhost ~]# nmcli connection modify eno16777736 +ipv4.addresses 192.168.126.200/24
[root@localhost ~]# nmcli connection up eno16777736
第二步,创建两个网页文件根目录,并定义网页内容
[root@localhost ~]# mkdir -pv /www/ip/{100,200}
[root@localhost ~]# echo this is 100 > /www/ip/100/index.html
[root@localhost ~]# echo this is 200 > /www/ip/200/index.html
[root@server html]# setenforce 0
[root@server html]# getenforce
Permissive
第三步,定义基于不同ip地址来访问网站的配置文件
在这里插入图片描述

[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# curl 192.168.126.200
this is 200
[root@localhost ~]# curl 192.168.126.100
this is 100
如果访问时显示的是apache默认的欢迎界面,则需要做如下操作:
[root@localhost ~]# setenforce 0

三、搭建静态网站——基于https协议的静态网站
[root@localhost ~]# yum install mod_ssl -y
[root@localhost ~]# cd /etc/pki/tls/certs/
[root@localhost certs]# make jiami.crt
[root@localhost ~]# vim /etc/httpd/conf.d/host.conf
<VirtualHost 192.168.80.128 >
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/jia.crt
SSLCertificateKeyFile /etc/pki/tls/certs/jia.crt
DocumentRoot /www/https
ServerName 192.168.80.128

<directory /www/https>
allowoverride none
require all granted

[root@localhost ~]# systemctl restart httpd
通过浏览器访问或者curl --insecure https://IP地址

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值