There are several reasons why you might want to run different Apache Virtual Hosts as separate users from the Apache user account. My most frequent usage is on my development machine to allow running from my home directory.
The most commonly recommended option for this purpose is MPM-ITK (a quick hack would be to add yourself to the www-data group using “sudo usermod -a -G www-data USERNAME”)
sudo apt-get install apache2-mpm-itk
sudo a2enmod mpm_itk
Modify the virtual host config file in /etc/apache2/sites-available
<Virtualhost *:80>
ServerName HOSTNAME
ServerAdmin webmaster@domain.com
<ifmodule mpm_itk_module>
AssignUserID USERNAME GROUPNAME
</ifmodule>
DocumentRoot /home/USERNAME/www/docs
ErrorLog /home/USERNAME/www/logs/error.log
CustomLog /home/USERNAME/www/logs/access.log combined
</Virtualhost>
PLEASE NOTE:
If you doing this on a machine that already had a default install where MPM-PREFORK is enabled you have to disable
sudo a2dismod mpm_prefork
sudo a2enmod mpm_itk
Pingback: dnetix
u cannott dismal mpm_prefork since mpm_itk needs mpm_prefork, says apache.
ERROR: The following modules depend on mpm_prefork and need to be disabled first: mpm_itk
In xenial you need to install libapache2-mpm-itk
sudo apt install libapache2-mpm-itk