How to add a sub-domain in 000-default file

oracle

New Member
Messages
430
Reaction score
0
Points
0
Hi here is my /etc/apache2/sites-enabled/000-default file:

Code:
NameVirtualHost *
<VirtualHost *>
    ServerAdmin admin@mysite1.com
    ServerName mysite1.com
    DocumentRoot /var/www
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www>
        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>

</VirtualHost>

<VirtualHost *>
    ServerAdmin admin@mysite2.com
    ServerName mysite2.com
    DocumentRoot /var/www/mysite2com
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www/mysite2com>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

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

    ErrorLog /var/log/apache2/error.log

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

    CustomLog /var/log/apache2/access.log combined
    ServerSignature On

    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>

<VirtualHost *>
    ServerAdmin admin@mysite2.com
    ServerName mysite3.com
    DocumentRoot /var/www/mysite3com
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www/mysite3com>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

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

    ErrorLog /var/log/apache2/error.log

    LogLevel warn

    CustomLog /var/log/apache2/access.log combined
    ServerSignature On
</VirtualHost>

Now I want to add a sub-domain tomy 3rd site. Something like:

http://devel.mysite3.com

I have tried various combination but I am just unable to create this sub-domain.

Can someone please help me with this??

Do we need to enable any module in apache for doing this??

Thanks in advance,
Imoracle
 

rockee

New Member
Messages
120
Reaction score
0
Points
0
You could add the ServerAlias directive to the vhost container that needs a sub-domain.

ServerAlias www.mysite3.com devel.mysite3.com <-- as many as you need - www is also a sub-domain usually simlinked to the main domain.

http://httpd.apache.org/docs/2.2/mod/core.html#serveralias
http://httpd.apache.org/docs/2.2/mod/core.html

<VirtualHost *>
ServerAdmin admin@mysite3.com
ServerName mysite3.com
ServerAlias www.mysite3.com devel.mysite3.com forum.mysite3.com
DocumentRoot /var/www/mysite3com
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/mysite3com>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

ScriptAlias /cgi-bin/ /var/www/mysite3com/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
Alternatively you can create a whole new container just for the sub-domain using the
ServerName devel.mysite3com
and including the ServerAlias directive also.

For search engine optimization the ServerName in all your containers can be www.domain.com which eliminates the need to do a redirect.
The ServerAlias would then have the main domain included - domain.com

<VirtualHost *>
ServerAdmin admin@mysite3.com
ServerName www.mysite3.com
ServerAlias mysite3.com www.mysite3.com devel.mysite3.com forum.mysite3.com
DocumentRoot /var/www/mysite3com
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/mysite3com>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

ScriptAlias /cgi-bin/ /var/www/mysite3com/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
BTW - mysite3.com links to a free porn site! :naughty:
Regards,
Rocky
 
Last edited:

oracle

New Member
Messages
430
Reaction score
0
Points
0
Hi,

Thanks for your reply but for some reason I am unable to make the sub-domain.

Here is what I added:

Code:
			 				<VirtualHost *>
    ServerAdmin [B]admin@mysite3.com[/B]
    ServerName devel.mysite3.com
    [B]ServerAlias devel.mysite3.com[/B]
    DocumentRoot [B]/var/www/mysite3com/devel[/B]
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory [B]/var/www/mysite3com/devel[/B]>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

    ScriptAlias /cgi-bin/ [B]/var/www/mysite3com/devel/cgi-bin/[/B]
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

Can you kindly tell me where I am doing wrong?

I restarted the apache after making the above changes in the 000-default file.

Thanks,
Imoracle
 

rockee

New Member
Messages
120
Reaction score
0
Points
0
oracle said:
<VirtualHost *>
ServerAdmin admin@mysite3.com
ServerName devel.mysite3.com
ServerAlias devel.mysite3.com
DocumentRoot /var/www/mysite3com/devel
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/mysite3com/devel>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

ScriptAlias /cgi-bin/ /var/www/mysite3com/devel/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
Edit:
Your following post seems to say that the above is correct so I have no need to reply to your previous post - so I deleted what I had posted in reply as it was irrelevant and obviously no further help is needed by me.

Rocky
 
Last edited:

oracle

New Member
Messages
430
Reaction score
0
Points
0
I think my config was correct because if I go to my Windows XP host file and add my server's IP and sub-domain, like this

xxx.yyy.zzz.aaa devel.mysite3.com

And then I go to open it, it works perfectly. I guess its some propagation issue, or I need to add something to my CNAME settings.

Any idea over this, coz I can see I am able to connect and work well if I add the above params in my host config file, but as soon as I remove the settings, it again says server not found.

Imoracle
 
Top