I don't really blog anymore. Click here to go to my main website.

muhuk's blog

Nature, to Be Commanded, Must Be Obeyed

January 14, 2013

Quick Debian tip for Testing Static HTML Sites

For trivial stuff directing your browser to file:///path/to/your/page.html does the trick. However if you need to test your page on a real webserver, setting one up can be a hassle. More than that, I dislike leaving crubmles of config files on my dev machine.

Here is my quick and not dirty solution; userdir plugin for apache. Basically I enable userdir and then place a symlink to my static content from it. Here’s the list of commands you need to run:

# Install Apache if it's not already installed
sudo aptitude install apache2
# Enable userdir
sudo a2enmod userdir
sudo service apache2 restart
# Create a symlink to your static site
cd $HOME
mkdir public_html
cd public_html
ln -s /path/to/your/static/site link_name
x-www-browser localhost/~username/link_name/index.html

This way you can host and un-host many static sites locally. I hope it helps.

If you have any questions, suggestions or corrections feel free to drop me a line.