Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Server Operation

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 21st April 2005, 18:36
redstar redstar is offline
Junior Member
 
Join Date: Apr 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Subdomains and Apache

A quick newbie-question: how do you set up subdomains in Apache? What I want to do is this:

I have a web site www.domain.com. Now I want to create a subdomain sub.domain.com, and when I enter it in my browser, I want to go to the same web site (www.domain.com).

RedStar
Reply With Quote
Sponsored Links
  #2  
Old 22nd April 2005, 11:47
jojo jojo is offline
Junior Member
 
Join Date: Apr 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can do it with the ServerAlias directive. A little example:

Code:
<VirtualHost aaa.bbb.ccc.ddd>
ServerName www.domain.com
ServerAdmin webmaster@domain.com
DocumentRoot /path/to/your/document_root
ServerAlias sub.domain.com
</VirtualHost>
Jojo
Reply With Quote
  #3  
Old 27th May 2006, 11:40
Dutzzu Dutzzu is offline
Junior Member
 
Join Date: May 2006
Posts: 8
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via ICQ to Dutzzu Send a message via MSN to Dutzzu Send a message via Yahoo to Dutzzu Send a message via Skype™ to Dutzzu
Default

hm...i have a question here ...

i found on net a similar code with the one gived by jojo

Code:
Listen 80
NameVirtualHost *

<VirtualHost *>
  ServerName www.domain.com
  DocumentRoot /home/httpd/htdocs/
</VirtualHost>

<VirtualHost *>
  ServerName subdomain.domain.com
  DocumentRoot /home/httpd/htdocs/subdomain/
</VirtualHost>
and i'm sure that it's gonna work ...

but now a noomb question .... where do i paste this code in httpd.conf ?

The begining of my httpd.conf looks like this ( i won't paste all file it's to large ) :


Code:
Listen 80
ServerRoot "/www/Apache2"
DocumentRoot "/www/webroot"

ServerName localhost:80
ServerAdmin admin@localhost

ServerSignature On
ServerTokens Full

DefaultType text/plain
AddDefaultCharset ISO-8859-1
Can anybody show me how should i modify the file ?

That's all Thanq

ps : and another noomb question .... witch of this two codes is better ?
Reply With Quote
The Following User Says Thank You to Dutzzu For This Useful Post:
zeroday (23rd December 2007)
  #4  
Old 27th May 2006, 14:34
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,747 Times in 2,578 Posts
Default

Quote:
Originally Posted by Dutzzu
but now a noomb question .... where do i paste this code in httpd.conf ?
This normally goes near the end of your httpd.conf. There should be an example section about virtual hosts. But it might also be in some included file. Which distribution do you use?

Quote:
Originally Posted by Dutzzu
ps : and another noomb question .... witch of this two codes is better ?
They do pretty much the same.
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #5  
Old 27th May 2006, 22:52
Dutzzu Dutzzu is offline
Junior Member
 
Join Date: May 2006
Posts: 8
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via ICQ to Dutzzu Send a message via MSN to Dutzzu Send a message via Yahoo to Dutzzu Send a message via Skype™ to Dutzzu
Default

First of all than'q for answering me falko

Now ... i've got the apache instalation from http://www.devside.net/web/server/free/download ( setup 1.16 ) ...

And about httpd.conf file ... it doesn't have any exemple ... i think it's not a very popular version of apache in all forums i looked the httpd.conf file looks different I hope that's not a problem

I think it's easyer if i put the file ... and if u have time & wish to help me ... to solve it easyer . So here's the file

And about the exemple u saied that it should be ... i found one in other file ( witch is in the same folder with httpd.conf ) named " httpd.default.conf " ... it has a lil' example at the end of the file .... here'is the file If this is what i searched i have to delet " # " before the example and replace it with the code i entered in first message ?

Thank you again for your time

Last edited by Dutzzu; 27th May 2006 at 23:11.
Reply With Quote
  #6  
Old 28th May 2006, 23:49
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,747 Times in 2,578 Posts
Default

I'd put

Code:
Listen 80
NameVirtualHost *

<VirtualHost *>
  ServerName www.domain.com
  DocumentRoot /home/httpd/htdocs/
</VirtualHost>

<VirtualHost *>
  ServerName subdomain.domain.com
  DocumentRoot /home/httpd/htdocs/subdomain/
</VirtualHost>
at the end of your httpd.conf and restart Apache.
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #7  
Old 29th May 2006, 10:30
unkn0wn unkn0wn is offline
Senior Member
 
Join Date: Mar 2006
Posts: 110
Thanks: 0
Thanked 0 Times in 0 Posts
Default

must i change some dns record for subdomain? or just edit httpd.conf
Reply With Quote
  #8  
Old 29th May 2006, 16:51
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,747 Times in 2,578 Posts
Default

Your DNS records for the subdomains must point to the correct IP address.
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #9  
Old 4th June 2006, 21:59
Dutzzu Dutzzu is offline
Junior Member
 
Join Date: May 2006
Posts: 8
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via ICQ to Dutzzu Send a message via MSN to Dutzzu Send a message via Yahoo to Dutzzu Send a message via Skype™ to Dutzzu
Default

Should i delete something from the start of the document ? or just paste that code at the end ?
Reply With Quote
  #10  
Old 5th June 2006, 15:25
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,747 Times in 2,578 Posts
 
Default

Paste the code at the end and comment out those directives if they are somewhere else in the file.
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 18:19.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.