阅读 40

搭建文件服务器

下载httpd

yum install -y httpd
复制代码

看看成功了没有

http://localhost

配置监听端口和隐藏目录

vim /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 9090

复制代码

去掉Indexes,这样页面就看不到目录结构了

<Directory "/var/www/html/file">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options   FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride None

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

复制代码
systemctl restart httpd
复制代码
netstat -nltp | grep 9090
复制代码

指定目录

先到默认的映射地址下

cd /var/www/html/
复制代码

接下来加一个软件映射存放文件的目录

ln -s /opt/file/ file
复制代码

访问

http://localhost:9090/file/

文章分类
后端
文章标签