【软件安装使用】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 <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 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)

1021 03:44:41 linux-4-192 systemd[1]: Starting The Apache HTTP Server...
1021 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
1021 03:44:41 linux-4-192 httpd[12902]: (13)Permission denied: AH00072: make_sock: could not bind to address 172.24.4.192:10080
1021 03:44:41 linux-4-192 httpd[12902]: no listening sockets available, shutting down
1021 03:44:41 linux-4-192 httpd[12902]: AH00015: Unable to open logs
1021 03:44:41 linux-4-192 systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
1021 03:44:41 linux-4-192 systemd[1]: Failed to start The Apache HTTP Server.
1021 03:44:41 linux-4-192 systemd[1]: Unit httpd.service entered failed state.
1021 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的权限。

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值