How to use different user and group for just one Virtual Host in Apache

apacheWith the mpm-itk that is a multi-processing module (MPM) you can run each virtualhost with it’s own user id and group id. This is basically used to make a shared hosting secured, since you don’t have to make all virtualhosts folders readeable by apache user.

mpm-itk is based on the traditional prefork MPM, which means it’s non-threaded; in short, this means you can run non-thread-aware code (like many PHP extensions) without problems.

Press continue reading for more.

$ sudo apt-get install libapache2-mpm-itk

How the virtual host should be configured:

<VirtualHost *:80>
  ServerName example.com
  DocumentRoot /path/to/web/root
  AssignUserId vhost-user vhost-group
</VirtualHost>

It is good to change website root to be owned by the user and the group set to the vhost, change it with

$ sudo chown -R vhost-user:vhost-group /path/to/webroot

Take care with this command, this will change all owner and group of your files in the specified path.

And finally start Apache

$ sudo service apache2 restart

Source: IT Solution

Comments

comments

Comments are Disabled