How do I get Apache to run as different users?
(I'm editing my post to hopefully make it clearer).
I am putting together a web server where I have multiple domains. For this example, I'll keep it simple and say we have two domains (though we could have lots more). test1.com and test2.com are the two domains.
I'm setting this up to test on a virtual machine in VirtualBox. So to go to the domains, you'd put in the browser (as an example) in the host: 192.168.1.4/test1.com to get there.
test1.com directory: /var/www/public_html/test1.com (set to 755, test1.com:test1.com owner:group).
test2.com directory: /var/www/public_html/test2.com (set to 755, test2.com:test2.com owner:group).
Script /var/www/public_html/test1.com/testwrite.php will use file_put_contents to write a test file.
Now if say the testwrite.php writes to /var/www/public_html/test1.com/test.txt the file should also be test1.com:test1.com owner:group.
If testwrite.php writes to /var/www/public_html/test2.com/test.txt then it should not be able to do this. It should instead do nothing or, if php is set to report errors to the browser, say that permission is denied to write the file.
I can't get this to work as I state above. I always get permission denied.
I tried installing suexec-custom and setting it up so that in the /etc/sites-enabled/test1.com.conf file it has:
SuexecUserGroup test1.com test1.com
But even after restarting apache2, it still shows permission denied.
Anyone know how to get this to work?
Last edited by RavenLX; 03-09-2015 at 08:59 PM.
Reason: Edited to better clarify what I am trying to do.
|