RHCE---day2作业

1.at 配置在5小时后,将 “This is a at task” 写入 root家目录中的at_test文件中

[root@localhost ~]# at now+5 hours
warning: commands will be executed using /bin/sh
at> echo "This is a task" > /root/at_test
at> <EOT>
at> <EOT>
job 10 at Wed Dec  1 13:45:00 2021

2.crontab配置,每周六,周日 9点半,14点 提醒我上RHCE课 写入root家目录中的cron_test文件中

[root@localhost ~]# crontab -u root -e
crontab: installing new crontab
[root@localhost ~]# crontab -u root -l #查看cron任务
30 9 * * 0,6,7 echo "提醒我上RHCE课" > /root/cron_test
0 14 * * 0,6,7 echo "提醒我上RHCE课" > /root/cron_test

3.安装httpd,并将访问apache服务器的首页修改为hello.html, 且内容为: “My Home Page is hello”

首先保证虚拟机上已经配置好yum源
配置yum源代码

cd /etc/yum.repos.d
[root@localhost yum.repos.d]# mv redhat.repo redhat.repo.bak   #做备份
[root@localhost yum.repos.d]# wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Cens-8.repo  #这里应用的是阿里云的源
yum clean all #清理缓存
yum makecache#重新创建缓存

安装httpd

[root@localhost ~]# yum install httpd -y
[root@localhost ~]# systemctl stop firewalld #关闭防火墙
[root@localhost ~]# setenforce 0 #将set设为宽容模式
[root@localhost ~]# systemctl restart httpd #重启服务
[root@localhost conf]# vim /var/www/html/index.html 

在这里插入图片描述
进入Windows浏览器输入虚拟机IP
在这里插入图片描述

4.虚拟主机:虚拟两台主机ip为100,200, 对应访问目录:/www/ip/100, /www/ip/200,并创建首页文件index.html
增加两个IP地址

mkdir -p /www/ip/{100,200}
nmcli c modify ens160  +ipv4.addresses 192.168.102.100/24 ipv4.gateway 192.168.102.2 ipv4.method manual 
nmcli c modify ens160  +ipv4.addresses 192.168.102.200/24 ipv4.gateway 192.168.102.2 ipv4.method manual 

查看新增加的两个IP
在这里插入图片描述
创建两个网页文件根目录,定义网页内容

[root@localhost conf]# mkdir -p /www/ip/{100,200}
[root@localhost conf]# echo this is 100 > /www/ip/100/index.html 
[root@localhost conf]# echo this is 100 > /www/ip/200/index.html 

基于不同IP来访问网站的配置文件
编辑配置文件

[root@localhost conf]# vim /etc/httpd/conf.d/host.conf 
<Directory "/www/ip">
AllowOverride none
Require all granted
</Directory>

#Listen 80
<VirtualHost 192.168.102.100:80>
DocumentRoot "/www/ip/100"
ServerName 192.168.102.100
</VirtualHost>
<VirtualHost 192.168.102.200:80>
DocumentRoot "/www/ip/200"
ServerName 192.168.102.200
</VirtualHost>

重启服务

[root@localhost conf]# systemctl restart httpd

在浏览器中访问

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值