当前位置: 代码网 > it编程>数据库>Mysql > 基于 Apache 的 httpd 文件服务器详解

基于 Apache 的 httpd 文件服务器详解

2024年07月22日 Mysql 我要评论
基于 apache 的 httpd 文件服务器文件服务器的简介httpd(http daemon,超文本传输协议守护进程的简称),运行于网页服务器后台,等待传入服务器请求的软件。httpd 能够自动回

基于 apache 的 httpd 文件服务器

文件服务器的简介

httpd(http daemon,超文本传输协议守护进程的简称),运行于网页服务器后台,等待传入服务器请求的软件。

httpd 能够自动回应服务器的请求,并使用 http 协议传送超文本及多媒体内容。

常见的 httpd 以下实现:

  • apache http server
  • cern httpd
  • cherokee
  • hiawatha
  • lighttpd
  • ncsa httpd
  • nginx
  • openbsd

这里我们使用应用最广泛的 apache http server 搭建 httpd 文件服务器。

文件服务器的搭建

所使用的服务器操作系统是 centos 7.9,使用 yum 命令直接安装 httpd,如 yum 源有问题或者非 centos 操作系统,需要先准备软件源以及安装命令,centos 的主机执行如下命令即可安装 httpd 服务。

sudo yum install httpd

安装完成后,需要修改 /etc/httpd/conf/httpd.conf 配置文件,重点修改的内容如下所示。

# httpd服务端口
listen 8000
# httpd服务用户
user apache
group apache
# httpd服务根目录
documentroot "/www/httpd"
# httpd服务根路径的权限
<directory "/www/httpd">
	# 展示文件列表以及软链接的内容
    options indexes followsymlinks
    # 不允许使用.htaccess文件来修改apache的配置。
    allowoverride none
    # 允许所有用户访问此目录中的内容,也即,对所有请求都允许访问该目录及其内容。
    require all granted
</directory>

配置修改完成后,还需要修改 /www/httpd 也即配置的 httpd 文件服务器的目录属主,这里直接修改为 apache:apache

chown -r apache:apache /www/httpd

使用 systemctl start httpd 即可启动 apache httpd 文件服务器,如下是常用的 httpd 命令。

# 启动 httpd 服务
systemctl start httpd
# 重启 httpd 服务
systemctl restart httpd
# 停止 httpd 服务
systemctl stop httpd
# 查看 httpd 服务状态
systemctl status httpd

httpd 服务启动后,即可通过页面访问文件服务器的 web 页面。

apache httpd 默认是 apache http server 的页面,这里可以直接删除 /etc/httpd/conf.d/welcome.conf 这个文件移除这个页面,也可以修改这个文件修改默认展示的页面,这里我们直接删除配置文件,并重启 apache httpd 服务,出现的页面如下。

文件服务器的使用

访问默认的页面,出现的内容为空,这是因为配置的文件服务器根目录下没有内容,这里我们在配置的文件服务器根目录下创建 nginx 目录,并传入 nginx 的安装包。

mkdir /www/httpd/nginx
mv nginx-1.24.0.tar.gz /www/httpd/nginx
# 这里要注意允许其他用户访问当前目录,否则会出现无权限的问题
chown -r 755 /www/httpd/nginx

访问文件服务的页面,就能够看到创建的 nginx 目录以及安装包。

点击页面上的文件名称,或者在服务器上使用 wget,即可下载对应的文件。

如上已经实现了文件服务器,但在浏览器中下载文件时,会提醒这是不安全的,这里使用 nginx 代理文件服务器并配置 ssl 证书即可避免这种问题。

到此这篇关于基于 apache 的 httpd 文件服务器详解的文章就介绍到这了,更多相关apache httpd 文件服务器内容请搜索代码网以前的文章或继续浏览下面的相关文章希望大家以后多多支持代码网!

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com