In Apache Web Server, is there a way to set user and group differently between virtual hosts? I want to run PHP script with the owner's permission (in mod_php).

2 Answers 2


Use one of the following:

  • suPHP - run PHP as a user
  • suExec - run CGI as a user (if you run PHP as CGI)

These will run PHP as the user you specify in your VirtualHosts configuration.

Chances are your linux distro will already have these available in a repository somewhere.

See http://forums.cpanel.net/f5/confusion-suphp-suphpexec-apache-suexec-117633.html


You can use apache2-mpm-itk which allows to customize Apache user and group used for each virtual host.

apt-get install apache2-mpm-itk

nano /etc/apache2/sites-available/mydomain.com

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName mydomain.com
    ServerAlias www.mydomain.com
    DocumentRoot /home/myuser/mydomain.com
    Options -Indexes
    AssignUserID myuser mygroup

See Create and set up an Apache virtual host for more details.

  • You have spared me of using ACL's. For the moment :-)
    – frr
    Commented Oct 10, 2019 at 8:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .