当前位置:网站首页>RHCE 作业三
RHCE 作业三
2022-08-05 18:43:00 【俗人不俗鸭】
目录
1.安装httpd,并将访问apache服务器的首页修改为hello.html, 且内容为: "My Home Page is hello"
2.虚拟主机:虚拟两台主机ip为100,200, 对应访问目录:/www/ip/100, /www/ip/200并创建首页文件index.html
1.安装httpd,并将访问apache服务器的首页修改为hello.html, 且内容为: "My Home Page is hello"
(1)安装httpd
[[email protected] ~]# yum -y install httpd
(2)创建首页hello.html,并添加内容
[[email protected] ~]# cd /var/www/html/
[[email protected] html]# echo "My Home Page is hello" > hello.html
[[email protected] html]# ll
total 4
-rw-r--r--. 1 root root 22 Jul 26 22:22 hello.html
(3)修改/etc/httpd/conf/httpd.conf配置文件中的默认首页为hello.html
[[email protected] conf]# vim /etc/httpd/conf/httpd.conf
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
#DirectoryIndex index.html
DirectoryIndex hello.html #将默认index.html改为hello.html
</IfModule>
(4)重启httpd服务
[[email protected] conf]# systemctl restart httpd
(5)访问测试
[[email protected] conf]# curl 192.168.5.129
My Home Page is hello
2.虚拟主机:虚拟两台主机ip为100,200, 对应访问目录:/www/ip/100, /www/ip/200并创建首页文件index.html
(1)为ens160网卡增加两个ip
[[email protected] conf]# nmcli c modify ens160 +ipv4.addresses 192.168.5.100/24
[[email protected] conf]# nmcli c modify ens160 +ipv4.addresses 192.168.5.200/24
[[email protected] conf]# nmcli c up ens160
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/10)
[[email protected] conf]# ip -4 addr show ens160
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
inet 192.168.5.129/24 brd 192.168.5.255 scope global dynamic noprefixroute ens160
valid_lft 1784sec preferred_lft 1784sec
inet 192.168.5.100/24 brd 192.168.5.255 scope global secondary noprefixroute ens160
valid_lft forever preferred_lft forever
inet 192.168.5.200/24 brd 192.168.5.255 scope global secondary noprefixroute ens160
valid_lft forever preferred_lft forever(2)新建目录/www/ip/100和/www/ip/200,并分别添加index.html
[[email protected] ~]# mkdir -p /www/ip/{100,200}
[[email protected] ~]# cd /www/ip/
[[email protected] ip]# echo "this is 100" > /www/ip/100/index.html
[[email protected] ip]# echo "this is 200" > /www/ip/200/index.html
(3)在/etc/httpd/conf.d/目录下添加配置文件myhosts_ip.conf
[[email protected] ip]# cd /etc/httpd/conf.d/
[[email protected] conf.d]# vim myhosts_ip.conf
<Directory "/www/ip">
AllowOverride None
Require all granted
</Directory>
<VirtualHost 192.168.5.100:80>
DocumentRoot "/www/ip/100"
</VirtualHost>
<VirtualHost 192.168.5.200:80>
DocumentRoot "/www/ip/200"
</VirtualHost>
~ (4)重启httpd服务
[[email protected] conf.d]# systemctl restart httpd
(5)将selinux调为permissive模式
[[email protected] conf.d]# getenforce
Enforcing
[[email protected] conf.d]# setenforce 0
[[email protected] conf.d]# getenforce
Permissive
(6)访问测试
[[email protected] conf.d]# curl 192.168.5.100
this is 100
[[email protected] conf.d]# curl 192.168.5.200
this is 200
3.配置不同端口的虚拟主机访问apache服务器
(1)新建目录/www/port/8080和/www/port/9090,并分别添加index.html
[[email protected] conf.d]# mkdir -p /www/port/{8080,9090}
[[email protected] conf.d]# echo "this is page for port 8080" > /www/port/8080/index.html
[[email protected] conf.d]# echo "this is page for port 9090" > /www/port/9090/index.html
(2)在/etc/httpd/conf.d/目录下添加配置文件myhosts_port.conf
[[email protected] conf.d]# cd /etc/httpd/conf.d/
[[email protected] conf.d]# vim myhosts_port.conf
Listen 8080
Listen 9090
<Directory "/www/port/">
AllowOverride None
Require all granted
</Directory>
<VirtualHost 192.168.5.100:8080>
DocumentRoot "/www/port/8080"
</VirtualHost>
<VirtualHost 192.168.5.100:9090>
DocumentRoot "/www/port/9090"
</VirtualHost>
~ (3)重启httpd服务
[[email protected] conf.d]# systemctl restart httpd
(4)将selinux调为permissive模式
[[email protected] conf.d]# getenforce
Enforcing
[[email protected] conf.d]# setenforce 0
[[email protected] conf.d]# getenforce
Permissive
(5)访问测试
[[email protected] conf.d]# curl 192.168.5.100:8080
this is page for port 8080
[[email protected] conf.d]# curl 192.168.5.100:9090
this is page for port 9090
边栏推荐
猜你喜欢

div网页布局(做一个简单网页界面为例)

【教程1】疯壳·ARM功能手机-开发板上电教程
![[南京大学]-[软件分析]课程学习笔记(二)-IR](/img/a6/9331ea559812049bfe08666cdb35cc.png)
[南京大学]-[软件分析]课程学习笔记(二)-IR

BFD实验演示(Huawei路由器设备配置)

元器件选型实例(一、如何选一款合适的 DC-DC )

npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.

【学术相关】最新整理!绝对不能错过的130个学术网站和26个科研工具

为什么企业需要使用 Wiki 工具?

荣威RX9年内上市 荣威公布未来产品计划

Redis(三)session共享
随机推荐
译文推荐|深入解析 BookKeeper 协议模型与验证
(c) meet structure
分布事务和分布式锁
包载信使RNA(mRNA)的虫草多糖脂质体|冬虫夏草多糖脂质体包载小干扰RNA(siRNA)
零基础学黑客,该怎么学?
金仓数据库KingbaseES客户端编程接口指南-DCI(2. 概述)
七夕限定 | 龙凤呈祥2款包袱瓶数字藏品全网独家发售
JVM-第三章 运行时数据区概述及线程
JUC并发编程:第二季
2022杭电多校六 1009-Map (巴那赫不动点)
1. Reporting platform planning
齐岳|超支化聚缩水甘油接枝磁性Fe3O4纳米粒子(HPG-grafted MNPs)
怎样设计产品的兼容性测试更好?
国标视频云服务EasyGBS如何正确调阅实时录像接口?
CSDN社区图书馆活动之开书大吉(书评一)
JVM-第四章 程序计数器
进程间通信(IPC)
RNA甲基化修饰种类
bash_profile 重启后不生效
力扣每日一题-第49天-724. 寻找数组的中心下标