HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Server Operation (http://www.howtoforge.com/forums/forumdisplay.php?f=5)
-   -   Subdomains and Apache (http://www.howtoforge.com/forums/showthread.php?t=23)

redstar 21st April 2005 17:36

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

jojo 22nd April 2005 10:47

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

Dutzzu 27th May 2006 10:40

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:o .... 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 ? :D

That's all :) Thanq

ps : and another noomb question :o .... witch of this two codes is better ?

falko 27th May 2006 13:34

Quote:

Originally Posted by Dutzzu
but now a noomb question:o .... 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 :o .... witch of this two codes is better ?

They do pretty much the same.

Dutzzu 27th May 2006 21:52

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 :)

falko 28th May 2006 22:49

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.

unkn0wn 29th May 2006 09:30

must i change some dns record for subdomain? or just edit httpd.conf

falko 29th May 2006 15:51

Your DNS records for the subdomains must point to the correct IP address.

Dutzzu 4th June 2006 20:59

Should i delete something from the start of the document ? or just paste that code at the end ? :confused:

falko 5th June 2006 14:25

Paste the code at the end and comment out those directives if they are somewhere else in the file.


All times are GMT +2. The time now is 15:17.

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