Enable Apache Userdir on Ubuntu 24.04
The Apache Userdir module on Ubuntu 24.04 lets you host a personal website straight from your computer’s home folder using a simple web address like `yourserver.com/~yourusername`.
This built-in tool turns on a special feature in the Apache web server so friends and visitors can see any web pages you put inside a `public_html` folder in your user account.
Sharing files or running a small personal site this way takes just a few quick steps and saves you from dealing with complicated server settings.
Enable the Apache Userdir module by running `sudo a2enmod userdir` and then restart Apache with `sudo systemctl restart apache2`. This allows users to host content from a `public_html` directory in their home folder.
Enable Userdir
Installing Apache clears the path to enable the Userdir feature by running the command below.
sudo a2enmod userdir
Restarting Apache applies these changes immediately.
sudo systemctl restart apache2
Enabling the feature completes the primary configuration phase.
Test Apache Userdir
Testing Apache Userdir on Ubuntu 24.04 confirms whether personal webpages function correctly.
Creating a public_html document root in the home directory starts the testing process.
mkdir ~/public_html
Securing the new folder requires updating its permissions.
chmod 711 $HOME
chmod 755 ~/public_html
Adding a basic HTML 'index.html' file follows next with the command below.
nano ~/public_html/index.html
Inserting the lines below into the file populates the page content.
<html>
<title>My basic HTML page</title>
<body>
<p style="width: 100%; font-weight: bold; font-size: 60px; text-align: center;">
UserDir is enabled!
</p>
</body>
</html>
Saving and exiting finalises the file creation.
Web browsers can display files from the home directory once the Apache Userdir module is active. Opening a browser and navigating to `http://localhost/~yourusername/yourfile.html` loads specific files like `index.html`. Replacing `yourusername` with an actual Ubuntu username and `yourfile.html` with the target file name ensures the URL resolves properly.
http://example.com/~richard/
Appending the ~username after the server hostname or IP address completes the link structure.

That completes the setup process.
Conclusion:
Wrapping things up, web pages on Ubuntu 24.04 are now fully accessible through Apache's Userdir feature. Keep these key takeaways in mind:
- User Empowerment: Users can host web content directly from their home directories without server administration.
- Easy Access: With a simple URL format, files become accessible online.
- Quick Setup: Enabling Userdir is straightforward, requiring just a few commands in the terminal.
- Secure Configuration: Setting appropriate permissions ensures that directories are safe while allowing public access.
- Test Your Setup: Creating and viewing a basic HTML page is a simple test to confirm that the Userdir feature functions correctly.
Completing these steps unlocks the full potential of Apache's web hosting capabilities.
Was this guide helpful?
About the Author
Richard
Tech Writer, IT Professional
Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.
[…] Userdir is a feature in the Apache HTTP Server that allows users to have web directories. When enabled, users can create content in their home directories to host their web pages. […]