Enabling Apache user home public_html directory in Ubuntu 7.10

I recently scrapped my old Gutsy installation (which was an upgrade from Feisty) in favor of a clean one. I keep my home directory on a different partition so I lost none of the data. I frequently develop web applications and for convenience I work in my home directory, so I access them via http://localhost/~username/webapp. The advantage of this is not having to change ownership of the /var/www directory, or worse, give system wide permissions over it.

This won’t work with the default Apache configuration in Gutsy. In order to enable the user-specific public_html directory open up a terminal and switch to the apache module config directory:

cd /etc/apache2/mods-enabled

Edit: As azaman rightfully outlines in the comments, it’s easier (and safer) to just enable the module via a2enmod userdir and then restart httpd.

If you list all the files inside this directory you’ll notice that all of them are actually symbolic links. To enable mod_userdir, which is the module you’re interested in, you’ll have to create two symlinks to the relevant files:

sudo ln -s ../mods-available/userdir.load

sudo ln -s ../mods-available/userdir.conf

All done! Now restart Apache via:

sudo apache2ctl restart

Congratulations! You can now access the web applications stored in your /home/username/public_html directory via http://localhost/~username/

Share and Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blinkbits
  • BlinkList
  • del.icio.us
  • digg
  • Fark
  • Furl
  • Reddit
  • Spurl
  • YahooMyWeb

6 comments so far

  1. Ion January 2, 2008 12:24 pm

    Hi,

    This live should be changed:

    sudo ln -s ../mods_available/userdif.load

    wuth this line:

    sudo ln -s ../mods-available/userdir.load

  2. Clau January 2, 2008 3:41 pm

    Yes, of course, sorry about that, thanks. Typo, typo…

  3. azaman January 10, 2008 6:40 am

    In Gutsy, to enable the module, just type a2enmod userdir
    then reload apache2

  4. paul January 28, 2008 8:29 pm

    Can’t read that!

    Can’t read that!

    Ubuntu users have howtos for everything! (WTF) “HOWTO start my computer”

  5. Junior May 17, 2008 1:30 pm

    Hey, just wanted to let you know that there is an error in your code.

    sudo ln -s ../mods_available/userdir.load

    should be:

    sudo ln -s ../mods-available/userdir.load

    This will help those who copy and paste the code in.

  6. Clau June 8, 2008 9:36 pm

    You’re right, thanks.

Leave a comment

Please be polite and on topic. Your e-mail will never be published.