-2

I haven't found a plain-English, strict answer for this.

Relative backgound info: I have a Drupal 6 site. We use the domain module to provide content for 11 different domains. Some domains are like www.abc.com, www.def.com and some are like sesl.mysite.com which seem to be a sub-domain of mysite.com. These all work. Some other European domains are pointed to our mysite.com domain at their servers so once their www.oursite.com resolves to mysite.com, the Domain access module interprets and says, "Keep www.oursite.com in the browser, but feed all this content from our database at www.mysite.com". This is all just info. No problem with any of this.

What I haven't found yet, is that if I add a new sub-domain such as hr.mysite.com, is there a simple file on my Apache2 server where I need to enter that new sub-domain as well to make it work....OR... is "DNS management" ALSO needed? We handle everything here...this is a company that hosts our own sites and, as mentioned above, we seem to have some sub-domains but I've become frustrated with all the info I've found dealing with people playing around 'locally' instead of instructions for 'live' servers that are out there on the net.

I'm not sure where else or what else I have to do to get this new sub domain to work. I inherited this site and am a front-end dev, not an IT Sysadmin/ back-end or server guy.

In my /etc/apache2/sites-available/default file I have this:

VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /data/drupal
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /data/drupal/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

which is confusing because I don't see our actual domain anywhere, nor anything that looks like one of the sub-domains.

Can someone point me in the right direction?

  • That VirtualHost will simply send all traffic to your server to the same `DocumentRoot`: `/data/drupal`. You probably won't have to change the Apache configuration, only the Drupal ones. And yes, you do need to point the DNS at it. – Tom van der Woerdt Jul 10 '13 at 19:03
  • http://serverfault.com/questions/423644/hosting-multiple-distinct-folders-for-distinct-domains/423646#423646 – user9517 Jul 10 '13 at 19:04

1 Answers1

1

As Tom says, you need a bit of both. But the apache configuration depends on where you want the new subdomain to point.

If you want the sub domain to point at the site you posted the apache config for, then you need to add

ServerAlias newsubdomain.example.com

So that apache knows which virtualhost stanza to use.

If you want to send newsubdomain.example.com to a new site, then you need something like this:

<VirtualHost *:80>
ServerName newsubdomain.example.com
DocumentRoot /some/location/for/your/site
ErrorLog /some/new/error/log/location/newsubdomain.example.com.error.log
</VirtualHost>

Note the error log isnt a requirement, but I think its a good idea to keep logs separate. You can do something similar with the access log if you wish.

In your DNS control panel, you then create a new A (or host) record for newsubdomain.example.com poiting at the public IP address of your server. You can copy the IP address from your existing domains.

This is called NameBased VirtualHosts and you can read about it here: http://httpd.apache.org/docs/current/vhosts/name-based.html

GeoSword
  • 1,657
  • 12
  • 16