Entries Categorized as 'Linux'

Sharing Files using Apache 2 on Linux

Date April 28, 2009

Sometimes on my Ubuntu box I want to share files with either my other machines, or with other people to give them quick access to download whatever they want from my machine. Instead of using ftp, rsync, or scp or a network drive even, I like to use Apache to set up a quick web directory.

This configuration has only been tested with my current Apache 2.2.8 version, so give it a go, and it could work with your version.

Just to note, most of these commands need root access so use sudo or su if you get an access denied message.

What you need to do is go to the Apache configuration files in the sites enabled folder:

$ cd /etc/apache2/sites-enabled/

Use nano or vi to create a new file, call it myshare or whatever you like:

$ nano myshare

Then add the following configuration and replace the _WEBDIR, _USER, _SHARED with the information from your machine.

Alias /_WEBDIR "/home/_USER/_SHARED/"
<Directory "/home/_USER/_SHARED/">
          Order allow,deny
          Options Indexes
          Allow from 127.0.0.1
          Allow from All
</Directory>

Save the file and enable the configuration using the a2ensite command:

$ a2ensite myshare

Then restart apache:

$ apache2ctl restart

And there you have it!

Bad Behavior has blocked 957 access attempts in the last 7 days.