I followed Falco's tutorial and everything now works as expected for 2 users (e.g. john and alice) with their relevant directories (/var/www/john
and /var/ww/alice
).
Now, I want to go to the next level: instead of defining different vhosts at /etc/apache2/sites-available/<username>
and restarting Apache, I need dynamically configured mass virtual hosting.
Say, my DNS server has records for: another.site.example.com
, I want it's home directory to be at /var/www/another.site/web
.
The problem is all these configuration settings for suexec and mod_fcgid.
I ended to this draft of my httpd.conf
(or should I create a file like /etc/apache2/sites-available/mass_virtual
?):
NameVirtualHost *:80
#default virtual host
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
ServerAdmin [email protected]
DocumentRoot /var/www/root/web/
<IfModule mod_fcgid.c>
SuexecUserGroup web-admin web-admin
<Directory /var/www/root/web/>
Options +ExecCGI
Options -Indexes
AllowOverride All
AddHandler fcgid-script .php
FCGIWrapper /var/www/php-fcgi-scripts/root/php-fcgi-starter .php
Order allow,deny
Allow from all
</Directory>
</IfModule>
# ErrorLog /var/log/apache2/error.log
# CustomLog /var/log/apache2/access.log combined
ServerSignature Off
</VirtualHost>
#3rd-level subdomain virtual hosts
<VirtualHost *:80>
UseCanonicalName Off
ServerAlias *.example.com
#problematic email!
ServerAdmin [email protected]
#is this /var/www/another.site/web or /var/www/www.another.site/web for
#a request for www.another.site.example.com ?
VirtualDocumentRoot /var/www/%-3+/web
<IfModule mod_fcgid.c>
#problematic group and user!
SuexecUserGroup web1 web1
<Directory /var/www/*/web/>
Options +ExecCGI
Options -Indexes
AllowOverride All
AddHandler fcgid-script .php
FCGIWrapper /var/www/php-fcgi-scripts/*/php-fcgi-starter .php
Order allow,deny
Allow from all
</Directory>
</IfModule>
# ErrorLog /var/log/apache2/error.log
# CustomLog /var/log/apache2/access.log combined
ServerSignature Off
</VirtualHost>
As you can see from the comments I have a problematic
ServerAdmin [email protected]
, aSuexecUserGroup web1 web1
and aVirtualDocumentRoot /var/www/%-3+/web
configuration!Moreover, to ensure security I think
IfModule
shouldn't exist-ifmod_fcgid
can't load then neither should the server and,instead of
Alow from all
, I think I should haveDeny from all
and open-up a php-library directory instead!
Thanks.
OK, as I have no replies I'll try the half part of my proposed solution(?): use of mod_userdir to force execution of suexec
Let's create the following /etc/apache2/httpd.conf
Let's create a
mass_virtual
at/etc/apache2/sites-available/
Problem: If I uncomment first line I get a warning on server restart that there are no virtual hosts!!
Let's create my user bob
Let's create a .htaccess at
/var/www/bob/public_html
Let's hit my browser to
www.example.com/info.php
orexample.com/info.php
...as expected but,
let's move to
www.example.com/~bob/info.php
let's see errors
As you can see there are NO errors BUT
mod_fcgid
is NOT enabled to run the .php file and apache tries to send it as normal file!!! Any ideas how to solve this?