Ubuntu Apache2 - run VHOST as different user
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
Webmentions
No webmentions yet. Be the first to send a webmention !