• centos使用httpd搭建文件下载服务器教程


    前言
    工作中遇到需求,需要搭建一个HTTP文件服务器来共享文件。
    需求比较简单:共享一个目录下的文件,让其他人能够通过HTTP方式下载。
    之前使用Python内置的HTTP文件服务功能,但效果不佳。所以更换方案,采用httpd搭建。

    一、配置内网repo

    wget --ftp-user=xxx --ftp-password=xxx ftp://xxx/centos7/centos7.sh
    chmod 777 centos7.sh
    ./centos7.sh

    二、安装httpd

    执行命令
    yum install httpd

    三、配置httpd

    vi /etc/httpd/conf/httpd.conf

    3.1 修改端口号

    # 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 # 根据实际情况修改

    3.2 修改目录权限

    #
    # Deny access to the entirety of your server's filesystem. You must
    # explicitly permit access to web content directories in other
    # <Directory> blocks below.
    #
    <Directory />
    AllowOverride none
    # Require all denied 默认设置,拒绝所有访问请求
    Options All # 显示目录结构,以便用户浏览下载
    </Directory>

    3.3 修改共享目录

    #
    # 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 "/data/" # 根据实际情况修改
     
    #
    # Relax access to content within /var/www.
    #
    <Directory "/data"> # 根据实际情况修改
    AllowOverride None
    # Allow open access:
    # Require all granted
    # Allow from all
    </Directory>
     

    四、修改文件目录权限

    权限不对,会出现无权限访问的错误。目录名请根据实际情况修改。
    chmod -R 755 apks/ # 根据实际情况修改
    chmod -R 755 shared/ # 根据实际情况修改

    五、启动httpd服务

    systemctl start httpd

    六、其他常用命令

    重启httpd服务
    systemctl start httpd
  • 相关阅读:
    《Linux设备驱动开发详解(第2版)》配套视频登录51cto教育频道
    异常Address already in use: JVM_Bind的处理
    你的Jsp页面有黄×么,有黄色问号么?Multiple annotations found at this line:
    dispatch_get_current_queue 废弃
    二叉树代码(较全)
    ArrayList and LinkedList
    android的tabhost+RadioGroup+PopupWindow
    子进程继承父进程的当前工作目录的问题
    oracle AWR深入研究分析,如何使用
    Linux下对后台进程通过kill传递信号不起作用的问题
  • 原文地址:https://www.cnblogs.com/xiaoming/p/15619234.html
Copyright © 2020-2023  润新知