Skip to content
Follow
Ubuntu Linux

Enable Apache Userdir on Ubuntu 24.04

Richard
Written by
Richard
Feb 19, 2025 Updated Jul 13, 2026 2 min read
Enable Apache Userdir on Ubuntu 24.04
Enable Apache Userdir on Ubuntu 24.04

Apache Userdir on Ubuntu 24.04 lets you host personal websites from your home directory.

This feature uses the `mod_userdir` module, turning on a special part of the Apache web server.

It lets you create simple web pages that friends or others can visit using a special address, like `yourserver.com/~yourusername`.

Files for your personal site usually go into a folder named `public_html` inside your home folder.

This is a neat trick for sharing files or running small personal projects without needing to be a server expert.

⚡ Quick Answer

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

With Apache installed, you can enable the Userdir feature by running the command below.

🐧Bash / Shell
sudo a2enmod userdir

Restart Apache once enabled to apply your changes.

🐧Bash / Shell
sudo systemctl restart apache2

Once the feature is enabled, there are no further configuration steps.

Test Apache Userdir

Testing Apache Userdir on Ubuntu 24.04 confirms if your personal webpages are functioning correctly.

First, run the command below to create a ‘public_html‘ document root in your home directory.

💻Code
mkdir ~/public_html
⚠️Warning
Update the permissions on the directory to ensure they are secure.
🐧Bash / Shell
chmod 711 $HOME
chmod 755 ~/public_html

Next, run the command below and add a basic HTML ‘index.html‘ file.

💻Code
nano ~/public_html/index.html

Copy and paste the lines below into the file and save.

💻Code
<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>

Save the file and exit.

Your web browser can now display files from your home directory using the Apache Userdir module. To view a file, like `index.html`, from your home folder, open your web browser and navigate to `http://localhost/~yourusername/yourfile.html`. Remember to replace `yourusername` with your actual Ubuntu username and `yourfile.html` with the name of the file you want to see.

💻Code
http://example.com/~richard/

Add the ~username after the server hostname or IP address.

Apache Userdir feature enabled on Ubuntu 24.04
Apache Userdir feature enabled on Ubuntu 24.04

That should do it~

Conclusion:

You can now host your web pages on Ubuntu 24.04 by enabling Apache’s Userdir feature. Here are the key points to remember:

  • 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.

With these steps completed, users can take full advantage of Apache’s web hosting capabilities.

Was this guide helpful?

Was this helpful?
Richard

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.

📚 Related Tutorials

How to Install i-doit on Ubuntu with Apache
CMS How to Install i-doit on Ubuntu with Apache
How to Install BoxBilling with Apache on Ubuntu Linux
Ubuntu Linux How to Install BoxBilling with Apache on Ubuntu Linux

1 Comment

Leave a Comment

Your email address will not be published. Required fields are marked *