In some school environments, you’ll see examples where teachers are given their website to publish materials for students to access. Instead of having to create multiple server blocks, the system administrator can use the UserDir feature to accomplish this. 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 feature for Apache web servers that allows user-specific directories to be accessed via Nginx. For example, when you enable this feature in Apache, users with accounts on the system will be able to share content in their home directories with the world via Apache. This tutorial assumes that you already have an Apache2 web server installed. If you haven’t, you may want to do that before continuing below.
Install Apache2 HTTP Server
First, run the commands below to install Apache2 HTTP Server on Ubuntu
Enabling UserDir on Apache2
To enable the Userdir module for Apache2 webservers, run the commands below 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 Then validate the settings below:
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. In the ~/public_html folder, create html documents to be shared and accessed via the web server. Restart the Apache2 webserver to load the settings. Now test it out by browsing to the server hostname or IP address followed by the username. example: http://example.com/~richard This is how the 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!