Web-based file and folder sharing with Apache-HTTP server

来源:互联网 发布:全国工商企业数据爬虫 编辑:程序博客网 时间:2024/04/29 03:48

Abstract

The post introduces how to make file sharing available using apache http server.


1. Introduction


File sharing is the practice of distributing or providing access to digital media, such as  computer programs, multimedia(audio, images, and video), documents or others. 

File sharing may be achieved in a number of ways, such as FTP, NFS, SAMBA, etc.  But web-based file sharing is a more convenient and user-friendly way to do so.


Apache is a web server that can do some very complicated things in conjunction with lots of other software but it can also be used on almost any computer to share files with other computers. 

2. Steps


Following is the steps of file sharing with apache http server version 2.4.x


1) install apache http server.
# sudo yum install httpd  (for centos/fedora)
# sudo pacman -S apache   (for archlinux)


2) modify apache http server's httpd.conf file and enable alias_module: 


# enable alias_module
LoadModule alias_module modules/mod_alias.so
LoadModule autoindex_module modules/mod_autoindex.so



3) add alias folder to share (within httpd.conf): 
for example:


# share folder
Alias /tmp C:/temp
<Directory  C:/temp>
    IndexOptions  FancyIndexing FoldersFirst  Charset=UTF-8  NameWidth=*
    Options  MultiViews  Indexes
    AllowOverride None
#Deny from 192.168.1.130
#Deny from 10.0.0.0/8
    Order allow,deny
    Allow from all


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



# or as this:

<IfModule alias_module> 
   Alias /BaiduDownload "E:/BaiduYunDownload/" 
   <Directory "E:/BaiduYunDownload/"> 
Options Indexes MultiViews
IndexOptions FoldersFirst   Charset=UTF-8
AllowOverride None 
Require all granted
   </Directory> 
</IfModule>




# or in file "conf\extra\httpd-autoindex.conf"


IndexOptions FancyIndexing HTMLTable VersionSort FoldersFirst NameWidth=*

# We include the /icons/ alias for FancyIndexed directory listings.  If
# you do not use FancyIndexing, you may comment this out.
#
Alias /icons/ "${SRVROOT}/icons/"
<Directory "${SRVROOT}/icons">
    Options Indexes MultiViews
    AllowOverride None
    Require all granted
</Directory>


Restart the httpd service , and you can access shared files and folder from your web browser.


That is all!

0 0