Why don't php files in subdomain run under same user/group as main domain (Webmin)?

744 Views Asked by At

System: LAMP stack running CentOS 6 and Virutalmin/Webmin.

I set up a subdomain using Webmin, within an existing main domain (also created with Webmin). The main domain runs as user 910, group 582. Placing a php script in the main domain's public_html dir with this code:

<? echo `whoami`; ?>

generates the username of the domain owner.

Placing the same script in the subdomain's public_html generates 'apache'.

Both directories and files have the same ownership (910:582).

In /etc/httpd/conf/httpd.conf both virtual hosts have the same SuexecUserGroup line:

SuexecUserGroup "#910" "#582"

I need the subdomain to run under the same user, so Wordpress can access the files directly. Otherwise I have to chown everything in the subdomain to apache:apache which is a security risk/bad practice.

What am I missing here?

Thanks!

1

There are 1 best solutions below

0
On BEST ANSWER

Turns out this issue was due to several things:

  1. mod_php5 being enabled by default. Adding the directive

    php_admin_value engine Off
    

to the httpd.conf file for this virtual host disables mod_php5 which is incompatible with suexec.

  1. Add FCGIWrapper directive, which wasn't created by Webmin

    FCGIWrapper [home dir]/fcgi-bin/php5.fcgi .php
    
  2. Create the php5.fcgi file in the fcgi-bin directory. I just copied this file from another virtual host as it's only a bash shell script to launch the php interpreter.

  3. Add AddHandler and AddType directives to the main VirtualHost section and also the public_html <directory> section:

    AddType application/x-httpd-php .php
    
    AddHandler fcgid-script .php
    
  4. Ensure all file ownership and permissions are set correctly to the owner of the account.