【RHCSA服务搭建实验】之apache

虚拟web主机类型

一、基于端口

1.vim /etc/httpd/conf.d/vhost2.conf ---- --- 改变http服务默认访问路径

bash 复制代码
<directory /testweb1>
        allowoverride none    表示不允许覆盖其他配置
        require all granted     表示允许所有请求
</directory>
<virtualhost 0.0.0.0:80>    所有ip可以通过80端口访问
        documentroot /testweb1     指定了客户端请求网页时服务器返回文件的路径
        servername 192.168.85.129    服务器的域名
</virtualhost>
listen 81             监听81端口
<directory /testweb2>
        allowoverride none
        require all granted
</directory>
<virtualhost 0.0.0.0:81>   所有ip可以通过81端口访问
        documentroot /testweb2
        servername 192.168.85.129
</virtualhost>
:保存退出

2.分别在/testweb1,/testweb2目录下创建index.html文件,写入自己想要的内容

3.systemctl restart httpd --------- 修改了配置文件就需要重启该http服务

4.检查自己的防火墙是否放行http服务和81端口,如果没有就需要配置

bash 复制代码
firewall-cmd --add-service=http --permanent 
firewall-cmd --add-port=81/tcp --permanent 
firewall-cmd --reload

5.getenforce 检查一下自己是否是Permissive宽容模式,如果不是就 setenforce 0 临时开启,因为Enforcing需要验证页面标签,所以直接关了方便。

二、基于IP

1.vim /etc/httpd/conf.d/vhost2.conf ---- --- 改变http服务默认访问路径。

bash 复制代码
<directory /testweb1>
        allowoverride none
        require all granted
</directory>
<virtualhost 0.0.0.0:80>
        documentroot /testweb1
        servername 192.168.85.129
</virtualhost>
<directory /testweb2>
        allowoverride none
        require all granted
</directory>
<virtualhost 0.0.0.0:80>
        documentroot /testweb2
        servername 192.168.85.130
</virtualhost>
:wq

2.分别在/testweb1,/testweb2目录下创建index.html文件,写入自己想要的内容

3.systemctl restart httpd --------- 修改了配置文件就需要重启该http服务

4.nmcli connection modify ens160 +ipv4.addresses 192.168.85.130/24 ------ 添加一个ip地址,最好把原有的IP地址设置为手动修改模式 nmcli connection up ens160 重启一个网卡之后用ip add 命令可以看到ens160的两个ip地址。

5.getenforce 检查一下自己是否是Permissive宽容模式,如果不是就 setenforce 0 临时开启,因为Enforcing需要验证页面标签,所以直接关了方便。

三、基于web主机(域名)

1.vim /etc/httpd/conf.d/vhost2.conf ---- --- 改变http服务默认访问路径。

bash 复制代码
<directory /testweb1>
        allowoverride none
        require all granted
</directory>
<virtualhost 0.0.0.0:80>
        documentroot /testweb1
        servername www.xixi.com
</virtualhost>
<directory /testweb2>
        allowoverride none
        require all granted
</directory>
<virtualhost 0.0.0.0:80>
        documentroot /testweb2
        servername www.haha.com
</virtualhost>
:wq

2.分别在/testweb1,/testweb2目录下创建index.html文件,写入自己想要的内容.

3.systemctl restart httpd --------- 修改了配置文件就需要重启该http服务

4.vim /etc/hosts ---- 本地dns域名解析的配置文件,上网最先查本地的

bash 复制代码
添加本机的dns域名解析
192.168.85.129 www.xixi.com
192.168.85.129 www.haha.com
:wq

5.getenforce 检查一下自己是否是Permissive宽容模式,如果不是就 setenforce 0 临时开启,因为Enforcing需要验证页面标签,所以直接关了方便。

相关推荐
sadoshi1 天前
phpstudy的Apache添加AddType application/x-httpd-php .php .php5配置无效的处理方式
开发语言·php·apache
众乐乐_20081 天前
Uniapp中小程序调用腾讯地图(获取定位地址)
linux·服务器·apache
Johny_Zhao1 天前
CentOS Stream 10安装部署Zabbix 7.0网络监控平台和设备配置添加
linux·网络·网络安全·docker·信息安全·云计算·apache·zabbix·devops·yum源·huawei·系统运维·itsm·华三
小沈同学呀1 天前
Apache JMeter API 接口压测技术指南
jmeter·apache
何xiao树2 天前
Apache Ranger 2.2.0 编译
apache·rancher
wusam3 天前
Linux系统管理与编程20:Apache
linux·运维·服务器·apache·shell编程
Johny_Zhao3 天前
Ubuntu安装部署Zabbix网络监控平台和设备配置添加
linux·网络·mysql·网络安全·信息安全·云计算·apache·zabbix·shell·yum源·系统运维·itsm
搬砖的工人3 天前
Docker环境下的Apache NiFi安装实践踩坑记录
docker·容器·apache
曼岛_3 天前
[Java实战]Spring Boot 3 整合 Apache Shiro(二十一)
java·spring boot·apache
网安INF6 天前
Apache Shiro 1.2.4 反序列化漏洞(CVE-2016-4437)
java·网络安全·apache