Linux运维笔记-文档总结-Apache基本配置的介绍和语言支持,虚拟主机,访问控制的实现

本文详细介绍了在Red Hat 7.0系统中安装和配置Apache Web服务器的过程,包括基本参数设置、支持语言配置、访问控制及虚拟主机搭建等内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

以下所有操作都是在Red-hat 7.0上


|####################Apache的安装#####################|

yum install httpd -y
systemctl start httpd
systemctl stop firewalld
systemctl enable httpd
systemctl disable firewalld

|##################Apache的基本参数#################|

1.Apache的默认文件
index.html
2.Apache的配置文件
/etc/httpd/conf/httpd.conf
/etc/httpd/conf/*.conf
3.Apache的默认发布目录
/var/www/html
4.Apache的默认端口
80

|##################Apache的基本配置#################|

1.修改默认发布文件
vim /etc/httpd/conf/httpd.conf
164 DirectoryIndex westos.html
2.修改默认发布目录
** ##当selinux是disabled状态
vim /etc/httpd/conf/httpd.conf
**120 DocumentRoot “ /westos/www/test”
* Require all granted*
systemctl restart httpd
* ##当selinux是Enforcing状态*
vim /etc/httpd/conf/httpd.conf
120 DocumentRoot “ /westos/www/test”
systemctl restart httpd
semanage fcontext -a -t http_sys_content ‘/westos(/.*)?’ ##修改安全上下午
restorecon -RvvF /westos ##激活刚才修改的安全上下文

这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述

|####################Apache支持的语言#####################|

1.Apache支持的语言
HTML PHP CGI
2.cgi语言
mkdir /var/www/html/cgi ##建议cgi的默认目录
vim index.cgi
#!/usr/bin/perl
**vim /etc/httpd/conf/httpd.conf
* Options +ExecCGI*
* AddHandler cgi-script .cgi*
* systemctl restart httpd*

**(提示:做这个实验时,一定将selinux不要改成Enforing)

这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述

|##################Apache的访问控制###################|

1.设定ip访问
**vim /etc/httpd/conf/httpd.conf
* Order Allow,Deny ##这里别乱敲空格*
** Allow from All
** Deny from 172.25.254.250
**vim /etc/httpd/conf/httpd.conf
* Order Deny,Allow ##这里别乱敲空格*
** Allow from 172.25.254.250
** Deny from All

这里写图片描述
这里写图片描述
这里写图片描述

2.设定用户访问
创建认证用户
htpasswd -cm /etc/httpd/accessuser admin ##第一次创建时是-cm,如果第二次还是-cm,就会覆盖前面的内容
vim /etc/httpd/conf/httpd.conf
AuthUserFile /etc/httpd/accessuser ##用户认证文件
AuthName “Please input your name and password!”##提示信息
AuthType basic ##认证类型
Require valid-user ##认证用户,建立的都可以认证

这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述

|##################Apache的虚拟主机###################|

1.定义
可以让我们的一台Apache服务器在被访问不同域名时候显示不同的主页
2.建议测试页

这里写图片描述

3.配置

这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述

4.测试
在真机上先做好解析

这里写图片描述

这里写图片描述

这里写图片描述


The end

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值