Singpolyma

Technical Blog

Simple HTTP-based File Shares for Ubuntu

Posted on

This is a simple how-to for setting up automatic file sharing for users’ ~/Public folders in Ubuntu over HTTP with minimal overhead.

While this how-to is simple, it does use the command line. I happen to believe the command line is not so scary as the GUI marketing people would have you think, even to new users. It’s much easier to say “type this” and have a user understand than it is to try to describe the GUI actions.

First, install my subdirs script. This script finds a list of directories containing some other directory, and prints out the path to the subdirectory (if you don’t get that, never mind, you just need to know that you need in installed for this how-to).

sudo wget -O /usr/local/bin/subdirs http://github.com/singpolyma/singpolyma/raw/master/scripts/subdirs
sudo chmod +X /usr/local/bin/subdirs

Then, install the webfs HTTP server.

sudo apt-get install webfs

Edit the config file a bit:

sudo ${EDITOR=gedit} /etc/webfsd.conf

Change the line starting with web_root= to say:

web_root=/var/www

And the line starting with web_port= to say:

web_port=80

Then restart the server by running:

sudo /etc/init.d/webfs restart

Finally, to symlink the shares, run:

subdirs /home Public | while read DIR; do ln -s "$DIR" /var/www/$(basename "`dirname "$DIR"`"); done

You’re done!

The last command will have to be re-run every time you add a new user. Or you could add it as the second-last line in your /etc/rc.local file to make it run every time you boot.

Now people can just visit your computer in their webbrowser (if they’re on your local network… to get access from the Internet you have to configure your router, but you probably don’t want that anyway). The address of any Ubuntu computer in a webbrowser (on a computer than supports mDNS, such as other Ubuntu systems or Apple systems) is just hostname.local. For example, my computer is singpolyma-mini.local. For Windows users, they’ll have to type in your IP address (unless they install Bonjour for Windows).

You can find your IP address by running:

ifconfig | grep 'inet addr' | grep -v 127.0.0.1 | awk '{ print $2 }'

4 Responses

David Wolever

ah, cool – webfs looks neat.

Also worth knowing: `python -m SimpleHTTPServer` will serve the current working directory.

service dosn’t start

I run it directly via
webfsd -p 80
The website will show up but it didn’t load config file and
I cant change mime type setting for .mp4 so the browser didn’t download it .

Stephen Paul Weber

If you’re running the command directly like that, then it’s probably running as your user which is why the config file won’t work.

I don’t know if it’s easy to set up mime types with webfs, but you can always right-click and “Save link as…” to download any link on any webpage.

Leave a Response