The mod\_userdir module in Apache enables users to access their sites by entering a tilde (~) followed by their username in the URL. This allows users to have their own web space on the server without having to go through the main website. Here is how to use it:
1. First, ensure that the mod\_userdir module is installed and enabled in Apache. If not, install it by using the following command in the terminal:
For Ubuntu/Debian/System: \`\`\` sudo a2enmod userdir \`\`\` For CentOS/RHEL: \`\`\` sudo yum install mod\_userdir \`\`\`1. The next step is to configure the mod\_userdir. Open the Apache configuration file in a text editor. The location of this file may vary depending on your system, but it is usually /etc/httpd/conf/httpd.conf or /etc/apache2/apache2.conf.
1. Look for the section that contains ‘UserDir public_html’ (without quotes). This means that Apache looks for user directories in the ‘public_html’ directory of each user’s home directory. If this line is commented (starts with #), uncomment it by removing the # at the beginning of the line.
1. You can also change ‘public\_html’ to another directory if you prefer. For example, if you want Apache to look for user directories in the ‘websites’ directory of each user’s home directory, change the line to ‘UserDir websites’.
1. You also need to give Apache the necessary permissions to access the user directories. Look for a section that starts with ‘
1. Save the changes and exit the text editor.
1. Finally, restart Apache for the changes to take effect. The command to do this may vary depending on your system, but it is usually either systemctl restart httpd or systemctl restart apache2.
Now, each user on the system can create a ‘public\_html’ directory (or ‘websites’ directory if you changed it) in their home directory and place their HTML files inside. The files can be accessed by entering ‘http://[server-address]/~[username]’ in a web browser.