Setup Apache2 Userdir Module On Ubuntu 16.04 LTS Servers

Setup Apache2 Userdir Module On Ubuntu 16.04 LTS Servers

In most school environments is where you get to see Apache2 Userdir in action… each teacher is given his/her own website where he/she can publish materials for students to access… The URL to reach the teacher’s page is usually the domain name followed by /~teacher_name..

User Directory or Userdir for short is a module for Apache2 web server that allows user-specific directories to be accessed via Apache2. For example, when you enable this feature in Apache2, users with accounts on the system will be able to share content in their home directories with the world via Apache2..

This brief tutorial shows students and new users how to enable and configure it on Ubuntu 16.04 LTS Servers using Apache2…

To get started with enabling Userdir on Ubuntu 16.04 LTS, the steps below is a good place to start:

This tutorial assumes that you already have Apache2 web server installed. If you haven’t, you may want to do that before continuing below.

Step 1: Install Apache2 HTTP Server

First, run the commands below to install Apache2 HTTP Server on Ubuntu

sudo apt install apache2

Step 2: Enabling Userdir On Apache2

To enable Userdir module for Apache2 webservers, run the commands below

sudo a2enmod userdir

After running the commands above the feature will be enabled and ready to be used. The configuration file is at /etc/apache2/mods-enabled/userdir.conf. But you don’t have to do anything. It’s already configured with the best options.

To access the config file, run the commands below

sudo nano /etc/apache2/mods-available/userdir.conf

Then validate the settings below:

<IfModule mod_userdir.c>
     UserDir public_html
     UserDir disabled root

        <Directory /home/*/public_html>
             AllowOverride FileInfo AuthConfig Limit Indexes
             Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
             Require method GET POST OPTIONS

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Step 3: Creating User Directories

Now that the feature is enabled, all users have to do is run the commands below to create a folder in their home directories called public_html by running the commands below.

mkdir ~/public_html

In the ~/public_html folder, create html documents to be shared and accessed via the webserver.

Restart Apache2 webserver to load the settings.

sudo systemctl restart apache2.service

Now test it out by browsing to the server hostname or IP address followed by the username.


apache2 user dir


This is how Apache2 Userdir module is configured for users to allow users with accounts on the systems to share content from their home directories..

That’s it!


Comments (4)

  • zvodretiluret

    I really like your writing style, wonderful information, thanks for posting :D. “I will show you fear in a handful of dust.” by T. S. Eliot.

  • Google


    Usually posts some pretty fascinating stuff like this. If you’re new to this site.

  • React Element 87

    React Element 87

    Prior to the 2019 NFL draft, Nick Bosa deleted tweets that were critical of Colin Kaepernick, Beyonce and the movie “Black Panther”, and supportive of President Donald Trump because he “might end up in San Francisco.”

  • air jordan 4

    air jordan 4

    I simply desired to thank you so much again. I do not know the things that I could possibly have created without those suggestions discussed by you directly on that concern. Certainly was a real distressing condition for me personally, but observing th…

Leave a Reply