Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 3 down vote accepted

Good ol' Include should do the trick:

Include /myConfs/
share|improve this answer
really, that will include everything in there that directory??? – s2xi Aug 26 '11 at 3:37
Yup. Or, Include /myConfs/*.conf, if you just want files ending with .conf – Shane Madden Aug 26 '11 at 3:37
would i need to restart apache every time i make a new .conf file? – s2xi Aug 26 '11 at 3: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 3:51
service httpd restart, is that the same as the reload your speaking off? – s2xi Aug 26 '11 at 4:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.