CentOS配置httpd文件服务器

本文指导如何通过yum安装Apache Httpd,重点讲解了如何修改欢迎页面,将Options设置为Indexes,修改监听端口,并创建文件以便访问。一步步教你实现个性化设置和端口管理。

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

安装

首先安装httpd

yum -y install httpd

配置

修改欢迎页面

vim /etc/httpd/conf.d/welcome.conf

Options -Indexes改为Options +Indexes
如下:

<LocationMatch "^/+$">
	#修改的地方
    Options +Indexes
    ErrorDocument 403 /.noindex.html
</LocationMatch>

<Directory /usr/share/httpd/noindex>
    AllowOverride None
    Require all granted
</Directory>

Alias /.noindex.html /usr/share/httpd/noindex/index.html
Alias /noindex/css/bootstrap.min.css /usr/share/httpd/noindex/css/bootstrap.min.css
Alias /noindex/css/open-sans.css /usr/share/httpd/noindex/css/open-sans.css
Alias /images/apache_pb.gif /usr/share/httpd/noindex/images/apache_pb.gif
Alias /images/poweredby.png /usr/share/httpd/noindex/images/poweredby.png

修改监听端口
先找到配置文件

vim /etc/httpd/conf/httpd.conf

找到Listen 80将80修改为想要更换的端口,例如改为8000端口 如下

#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to 
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 8000

重启httpd服务

systemctl restart httpd

添加文件

httpd的默认根文件夹路径为 /var/www/html
可以如下操作

cd  /var/www/html
touch README.md
mkdir test

访问

浏览器打开{ip}:{端口号}即可访问,例如localhost:8000
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值