0

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).

1

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

3

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 webmaster@mydomain.com
    ServerName mydomain.com
    ServerAlias www.mydomain.com
    DocumentRoot /home/myuser/mydomain.com
    Options -Indexes
    AssignUserID myuser mygroup
</VirtualHost>

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.