November 11, 2009

Take Your Web Server With You

Photos, slide stacks, and huge documents can take up a lot of file space and we frequently need to distribute those files out to colleagues working on a project. When everybody is working in the office, you might have the luxury of being able to put your stuff on an Alfresco (Linux) or Sharepoint (Microsoft) server. The situation gets problematic when your team is working at a virtual office at the coffee shop downtown or off-site in some client conference room somewhere.

USB sticks can move files around, but they are slow and cumbersome. Email works too, until you hit that magical file size limit on your email system.

How about a portable Web server? You probably have one sitting right there on your Linux laptop, just ready to be used. If not, it is a simple matter of installing Apache and doing a little configuring.

Let's take a look.

On The Server Side

The Apache Web server is available for just about every distribution in the world. If it is not already loaded you can use the Synaptic package manager or apt-get to install it.

    rreilly>  sudo apt-get install apache2

The easiest way to serve files is to put them in your own public http directory. All users, on your machine can have a public Web directory, although you'll probably only need one. Putting your photos and big files in this public directory is much easier than placing them in one of the default Web page locations, which are most likely under the /www, /srv, or /var/www directories. Since they are your files, setting file permissions is simple and easy. If you copy files up to the one of the other Web directories, you'll need to change user over to root or use the sudo command. This whole exercise should be easy and fast.

You'll then need to enable the user directory in the Apache configuration file. The topic is well covered by Aimaz in the Ubuntu forums. I've spelled out the process here, with a little commentary. Uncomment or add these lines to the /etc/apache2/httpd.conf file.

   UserDir public_html
UserDir disabled root
   <Directory /home/*/public_html>
AllowOverride FileInfo AuthConfig Limit
Options Indexes SymLinksIfOwnerMatch IncludesNoExec

The userdir module also needs to be enabled.

    rreilly>  cd /etc/apache2/mods-enabled
    rreilly>  sudo ln -s ../mods-available/userdir.* 

Enter your password, if needed.

You can verify that the module is ready to go by checking the enabled directory.

    rreilly> ls

The userdir.load file should be listed.

Next, make a public directory for yourself and set the permissions so Apache can display the directory to Web users.

rreilly> mkdir ~/public_html/
rreilly> chmod o+rx ~/public_html

Users will need the URL of your files and the easiest thing to use is the IP address. The ifconfig command will give you that information.

    rreilly> ifconfig

Assuming you're using wifi, look for something to that effect. In this example, we would give the address to our colleagues.

          wlan0     Link encap:Ethernet  HWaddr 00:aa:bb:cc:dd:ff 
inet addr: Bcast: Mask:
RX bytes:7214711 (7.2 MB) TX bytes:1889437 (1.8 MB)

Similarly, if you are using a wired connection look for entries related to the eth0 device.

Lastly, restart the Apache2 server on your laptop

      rreilly> sudo /etc/init.d/apache2 restart

If you are running some type of firewall application, make sure that port 80 is open, so people can get to your files. I use Guarddog to set my firewall rules. I also make it a habit of unchecking various ports, when they are not specifically in use. This is especially important on a public wifi local area network, such as you might be using at your virtual coffee shop office.

Once everything is configured on the laptop, you can copy your files over to the public_html directory. You might grab a file from your photos directory. Here is an example.

   rreilly>  cp ~/photos/graphic1.png ~/public_html

You may have to change the permission on the file to something like the following.

   rreilly>  chmod 444 ~/public_html/graphic1.png

Now that the server is functioning, it's time to look to the client side.

On The Client Side

Of course to download files you'll need a browser. Firefox works fine on Linux and Windows laptops. One of the cool things about a little portable Web server like this, is that Windows users can use Internet Explorer to download files, without any trouble.

Fire up the browser and type the URL into the address box. Here's what we would use with our example.

Notice that there is no need for referencing the public_html directory. The username configuration takes care of that through the ~/rreilly mapping. Make sure you pay attention and put the files in the public_html under your home directory, on the server side.

The Apache index page.Figure 1 shows a screenshot of the browser page on my Asus Netbook. You'll notice that it is simply a listing of the files in the ~/rreilly/public_html directory on the server laptop. If you don't have an index.html or index.htm file there, you'll just get a directory listing. It allows people to simply pick what they want to download, click Save As, under their browser's file tab, and download the file to their machine.

Following normal http conventions, if you left-click on the file name, the picture will be displayed, if it is a graphic file. An .htm or .html file will be rendered as a Web page. And, a .txt file will show up on the browser screen as plain text. Use these capabilities to your advantage.

Another cool thing I wanted to mention is that you can add files to the public_html directory at any time. Your team members only need to refresh the browser screen, to see the new file. Each time you refresh a page it re-renders in the browser.

You might want to stop the Apache Web server, once you are done with the downloads, just to be on the safe side for security.

   rreilly>  sudo /etc/init.d/apache2 stop

We've looked at setting up the Web server on a laptop and how you can download large files onto colleagues networked laptops. What if there are no hotspots in sight and you still need to push out big files to your team.

Take a look at the next topic.

A Physical Private Network

We've all heard about virtual private networks. You know... they let you remotely attach to the company network so you can get to servers, securely browse pages, and so forth.

You can use your super portable laptop Web server on a small stand alone local area network simply by adding an inexpensive wifi router. The router, which most likely wouldn't be connected to a larger network or the Internet would become your own physical private network. This is one place where the corporate network admins don't really have much to say about a "rouge access point." Make sure you always adhere to their rules, of course. That's my disclaimer and I'm sticking by it.

The reason you might want your own router is because you still want to be able to push information out to your team and a network might not be available, such as in an emergency situation or some isolated corner of a convention hall, where your team are huddled in front of their laptops, feverishly working away on your project. Having your own little network would be a plus for security. Engage the security features of the router and then periodically check what machines are connected by running nmap on your laptop, just to make sure no bad guys have picked up your access point.

Trendnet 54 Mbps wireless-G routerI usually carry a little Trendnet 54 Mbps wireless-G router in my computer bag. See Figure 2 for a picture of my router. It has a small rubber-duck antenna and similarly small-sized power brick. Along with a spare six-foot CAT5 cable, I can have either a firewalled Internet router or a stand alone physical private network. The things are pretty useful and reasonably priced.


Running a Web server on your Linux laptop is definitely something that doesn't get much attention. You'll be happy that you set up your public_html directory and familiarized yourself with starting up Apache the next time you need to transfer a huge file to one of your associates.

This e-mail address is being protected from spambots. You need JavaScript enabled to view it
is a emerging technology consultant, writer, and portable computing expert. Early adopter tech trends, seminars, and writing projects are his stock-in-trade. His mission is to deliver exceptional value to his clients. Links to many of his articles appear on his Web site at

Click Here!