Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

up vote 1 down vote accepted

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

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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