Create separate web directory for each Linux user

Comments Off on Create separate web directory for each Linux user

In this article we will configure separate web directory for each Linux user. We will use Apache/2.2.15 (Unix)  web server and Red Hat Enterprise Linux Server.  We will create a web directory “reb” in user saadi’s home directory “/home/saadi” .  For each user we can follow the same strategy. You have to log in as a root user to complete the task.

Step-1: create a user

useradd salina

passwd salina
Changing password for user salina.
New password:

Step-2: Create a web directory in user home directory

su salina -c “/home/salina/public_html”

Step-3: Change the httpd.conf file to assign a domain for the user

Now we have to add the following Virtual Host segment at the end of  Apache configuration file “/etc/httpd/conf/httpd.conf” .

<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot /home/salina/reb
ServerName test.testdomain.com
ErrorLog /var/log/httpd/test.testdomain.com-error_log
CustomLog /var/log/test.testdomain.com-access_log common
</VirtualHost>

Make sure NameVirtualHost *:80 this line in uncommented  in httpd.conf file.

Step-4: Restart the Apachi.

service httpd restart