栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

【软件安装使用】linux下httpd服务开启后不能下载文件

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

【软件安装使用】linux下httpd服务开启后不能下载文件

摘要

Linux提供了httpd服务,相当于一个文件下载服务,开启后可以通过wget方式下载服务器上的文件。

但是开启服务后,下载文件提示权限问题,导致下载失败。本篇文章记录开启过程和下载失败的原因。

开启httpd服务

httpd一般是系统自带的服务,只需要修改一些默认的配置项,然后使用systemctl开启即可。

httpd配置文件目录:
/etc/httpd/conf/httpd.conf

需要关注的配置项:

# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the 
# 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 80

#
# documentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
documentRoot "/var/www/html"

第一个是监听端口,第二个是需要下载的文件根目录。
其他还有一些文件下载权限的配置,请查看配置文件中的解释。

开启服务:
systemctl start httpd

开启后则可以使用 wget http://ip:80/index.html 下载文件了。

问题1:服务开启失败
[root@linux-4-192 www]# systemctl status httpd.service
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since 四 2021-10-21 03:44:41 EDT; 3s ago
     Docs: man:httpd(8)
           man:apachectl(8)
  Process: 12902 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
 Main PID: 12902 (code=exited, status=1/FAILURE)

10月 21 03:44:41 linux-4-192 systemd[1]: Starting The Apache HTTP Server...
10月 21 03:44:41 linux-4-192 httpd[12902]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.24.4.192. Set the 'ServerName' directive globally to suppress this message
10月 21 03:44:41 linux-4-192 httpd[12902]: (13)Permission denied: AH00072: make_sock: could not bind to address 172.24.4.192:10080
10月 21 03:44:41 linux-4-192 httpd[12902]: no listening sockets available, shutting down
10月 21 03:44:41 linux-4-192 httpd[12902]: AH00015: Unable to open logs
10月 21 03:44:41 linux-4-192 systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
10月 21 03:44:41 linux-4-192 systemd[1]: Failed to start The Apache HTTP Server.
10月 21 03:44:41 linux-4-192 systemd[1]: Unit httpd.service entered failed state.
10月 21 03:44:41 linux-4-192 systemd[1]: httpd.service failed.
[root@linux-4-192 www]#

由于安全问题,httpd一般只允许使用默认的几个服务端口,如果使用其他端口则服务启动失败。
允许使用的服务端口包含:
80, 81, 443, 488, 8008, 8009, 8443, 9000

问题2:服务开启后,文件下载失败

下载文件时提示403。

这种一般是需要下载的文件没有执行权限,所以要通过chmod赋予775的权限。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/694785.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号