sub-domains w/ apache 2.0

PauloR
PauloR used Ask the Experts™
on
Hello,

How can I create sub domains in apache 2.0? I now have www.example.com running and would like to create mail.example.com, would I have to setup a virtual server in apache? Thanks for helping a noob.

Take care,
Paulo
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Yes, you need to create a virtual servers for that.
The best way is name based virtual hosts(Single ip address and two web sites).
The following is the sample httpd.conf file.
I am assuming your ip address is 10.10.10.5.

NameVirtualHost 10.10.10.5

<VirtualHost 10.10.10.5>
    ServerAdmin webmaster@10.10.10.5
    DocumentRoot /home/httpd/www.example.com
    ServerName www.example.com
    DirectoryIndex Index.html
    ErrorLog logs/www.example.com-error_log
    CustomLog logs/www.example.com-access_log common
</VirtualHost>

<VirtualHost 10.10.10.5>
    ServerAdmin webmaster@10.10.10.5
    DocumentRoot /home/httpd/mail.example.com
    ServerName mail.example.com
    DirectoryIndex Index.html
    ErrorLog logs/mail.example.com-error_log
    CustomLog logs/mail.example.com-access_log common
</VirtualHost>

Instead of 10.10.10.5 you can also use * to specify any number of hosts.
Create the DocumentRoot, ErrorLog and CustomLog as specified above and place the Index files in them as specified by DirectoryIndex then stop and start your httpd service.
service httpd stop
service httpd start.

Good Luck.

Author

Commented:
Hello prasadklk,

Thank you very much! I did what you mentioned and it worked perfect!

Take care,
Paulo
PauloR:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.

Author

Commented:
Great Answer, exactly what I need!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial