Run Vhosts Under Separate UIDs/GIDs Apache2

To run vhosts under separate UIDs/GIDs in apache is very easy with mpm-itk.  This will help secure your sites on your shared server.

First install apache2-mpm-itk

apt-get install apache2-mpm-itk

Next add a group and user

groupadd web1
useradd -s /bin/false -d /home/web1_admin -m -g web1 web1_admin

Now add this to the end of your vhost for your site. Be sure to place this inside the </virtualhost> tag and not outside of it.

AssignUserId web1_admin web1


For each of your sites you will user a different username and group. Now be sure to set your web directory to the correct user and group.

Example:

chown -R web1_admin:web1 /var/www/website

One thought on “Run Vhosts Under Separate UIDs/GIDs Apache2”

Leave a Reply

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