0

i want to make a somewhat dynamic subdomain thing for my members.

I looked into PHP, which didn't really meet all my requirements.

alos htaccess wasn't right for me either.

the only problem is that i need "real" subdomain but because each subomain can point to a diff DocumentRoot then I need PHP to open up a new .conf file and append the VirtualHost information.

I was thinking that since in PHP there is the RecursiveDirectoryIterator() which can used to include files like this

$cf = new RecursiveDirectoryIterator(dirname(__DIR__) . DS . "configuration");


    foreach (new RecursiveIteratorIterator($di) as $filename => $file) {
        if ($di->getFilename() != "." && $di->getFilename() != ".." && $di->getFilename() != "include.php") {
            require_once $filename;
        }
    }

is there a similar thing I can include in the httpd.conf file to include all the .conf files say in a folder called /myConfs

this way I can use PHP to make a new .conf file and inject the custom DocumentRoots and save it to /myConfs/user1.conf

Eli
  • 427
  • 2
  • 7
  • 18

1 Answers1

3

Good ol' Include should do the trick:

Include /myConfs/
Shane Madden
  • 114,520
  • 13
  • 181
  • 251
  • really, that will include everything in there that directory??? – Eli Aug 26 '11 at 03:37
  • Yup. Or, `Include /myConfs/*.conf`, if you just want files ending with `.conf` – Shane Madden Aug 26 '11 at 03:37
  • would i need to restart apache every time i make a new .conf file? – Eli Aug 26 '11 at 03:48
  • Apache doesn't look for new config without some prompting, but a `reload` will probably fit your needs without doing a full service restart. – Shane Madden Aug 26 '11 at 03:51
  • `service httpd restart`, is that the same as the reload your speaking off? – Eli Aug 26 '11 at 04:09
  • That'll restart the service completely, causing a bit of downtime. `service httpd reload`, or `/etc/init.d/httpd reload` should be what you want from a graceful config reload. – Shane Madden Aug 26 '11 at 04:17