In this example I will use the default Debian Apache vhost (you can find its configuration in /etc/apache2/sites-available/default) with the document root /var/www (if you have different vhosts, please adjust this to your situation), and I want this vhost to run as the user web1_admin and group web1.
If the user and group don't already exist, we can create them as follows:
Now we open the main Apache configuration (/etc/apache2/apache2.conf) and search for the section where the various MPMs (prefork, worker, etc.) are configured, and add something like this to it:
vi /etc/apache2/apache2.conf
[...]
<IfModule peruser.c>
ServerLimit 256
MaxClients 256
MinSpareProcessors 2
MaxProcessors 10
MaxRequestsPerChild 1000
# kill idle processors after this many seconds (0 to disable)
IdleTimeout 60
# kill hung processes after this many seconds (0 to disable)
ExpireTimeout 300
# set up a few multiplexer processes running as nobody
Multiplexer nobody nogroup
Multiplexer nobody nogroup
Multiplexer nobody nogroup
# Processor <user> <group> <chroot>
# chroot is optional
Processor web1_admin web1
</IfModule>
[...]
The Processor line is important - it tells Apache which user/group pair is allowed to run a vhost. If you have a second vhost that you want to run as user web2_admin and group web2, just add a second Processor line. You can even chroot the user/group by adding an optional directory:
[...]
Processor web1_admin web1 /var/www
[...]
We must also modify our vhosts, e.g. like this:
vi /etc/apache2/sites-available/default
[...]
<IfModule peruser.c>
# this must match a Processor line
ServerEnvironment web1_admin web1
# these are optional - defaults to the values specified above
#MinSpareProcessors 4
#MaxProcessors 20
</IfModule>
[...]
This must be in a <VirtualHost></VirtualHost> container. The ServerEnvironment line must match exactly one of the Processor lines from the mpm-peruser configuration (if you have defined a chroot in the Processor line, you must list the chroot here as well, e.g.:
Please do not use the comment function to ask for help! If you need help, please use our forum. Comments will be published after administrator approval.
Recent comments
9 hours 53 min ago
9 hours 58 min ago
11 hours 22 min ago
12 hours 10 min ago
12 hours 29 min ago
18 hours 1 min ago
23 hours 19 min ago
1 day 4 hours ago
1 day 9 hours ago
1 day 10 hours ago