Skip to content
Follow
Ubuntu Linux

Enable Nginx Userdir on Ubuntu 24.04

Richard
Written by
Richard
Feb 19, 2025 Updated Jun 20, 2026 3 min read
Enable Nginx Userdir on Ubuntu 24.04
Enable Nginx Userdir on Ubuntu 24.04

You enable Nginx Userdir on Ubuntu 24.04 by configuring Nginx to serve content directly from individual user home directories, typically within a `public_html` folder.

Nginx Userdir functionality allows each user to host their personal websites on the server without requiring full administrative access.

This setup mirrors Apache’s Userdir feature and is essential for shared hosting environments or when you want to give users the ability to publish their own web content easily.

⚡ Quick Answer

Configure Nginx by editing the default site file to add a location block for user directories. After saving the configuration, restart the Nginx service to apply the changes. Test by creating a `public_html` folder in your home directory and adding an `index.html` file.

Enable Userdir

Turning on Nginx Userdir on Ubuntu 24.04 is done by changing the default Nginx site settings.

🐧Bash / Shell
sudo nano /etc/nginx/sites-available/default

Then, edit the file and add the highlighted lines under the [server] block.

💻Code
server {
listen 80 default_server;
listen [::]:80 default_server;
#
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name _;

location ~ ^/~(.+?)(/.*)?$ {
alias /home/$1/public_html$2;
index index.html index.htm;
autoindex on;
}


.........
........

Restart Nginx once enabled to apply your changes.

🐧Bash / Shell
sudo systemctl restart nginx

There is nothing else to configure once the feature is enabled.

Test Nginx Userdir

Testing your Nginx Userdir setup on Ubuntu 24.04 lets you see if it’s working correctly.

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

💻Code
mkdir ~/public_html

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.

Finally, open your web browser and browse the file in your home directory using the format below.

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

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

Apache userdir feature enabled on a Linux server environment
Apache userdir feature enabled on a Linux server environment

That should do it~

Conclusion:

Enabling the Nginx Userdir feature on Ubuntu 24.04 provides users with a convenient way to host their personal web pages without requiring administrative access. Here are some key points to remember:

  • User-Friendly: Allows users to manage their web content from their home directory easily.
  • Configuration: Requires modification of the Nginx configuration file to include the necessary location block.
  • Permissions: It’s essential to set appropriate permissions for the public_html directory to ensure security.
  • Testing: A simple HTML file can be created to verify that the Userdir feature is working correctly.
  • Access: Users can access their web pages through a simple URL format (http://yourserver/~username).

By following these steps, users can effectively leverage Nginx’s capabilities to host their personal websites.

What is the default user for nginx?

The default user name is nobody. sets the name of a group whose credentials will be used by worker processes. After installation, the name can always be changed in the nginx. conf configuration file using the user directive.

Does nginx run on Ubuntu?

Nginx is available in Ubuntu's default repositories. Install it using the apt packaging system. First, update the local package index to access the most recent package listings, then install nginx : sudo apt update.

Which user runs nginx?

As you can see in the first column, the initial nginx master process is started with the root user account.

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 Setup WordPress with Nginx and Cloudflare on Ubuntu
CMS How to Setup WordPress with Nginx and Cloudflare on Ubuntu
How to Install Drupal with Nginx and Cloudflare on Ubuntu
CMS How to Install Drupal with Nginx and Cloudflare on Ubuntu
How to Setup Joomla on Ubuntu with Nginx & Cloudflare
CMS How to Setup Joomla on Ubuntu with Nginx & Cloudflare
How to Install Monica CRM on Ubuntu with Nginx
CMS How to Install Monica CRM on Ubuntu with Nginx

No comments yet — be the first to share your thoughts!

Leave a Comment

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