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!
Turns out this issue was due to several things:
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.
Add FCGIWrapper directive, which wasn't created by Webmin
FCGIWrapper [home dir]/fcgi-bin/php5.fcgi .php
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.
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
Ensure all file ownership and permissions are set correctly to the owner of the account.