LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-05-2007, 03:54 PM   #1
Alotau
Member
 
Registered: Jan 2005
Location: Fremont, CA
Distribution: Red Hat 9
Posts: 58

Rep: Reputation: 15
Have www.mysite.com working, how to get www2.mysite.com set up?


Hi all,

I am running Apache on Red Hat and my home website works fine. I am pretty new to all of this, but what I'd like to do is have other 'sites' with my domain, like instead of www.mysite.com, something like www2.mysite.com or blah.mysite.com.

I assume it isn't too hard to do? Hopefully someone can just point me to some documentation or let me know how to change a configuration file somewhere. I'd gladly provide more info about my system if it's helpful.

Thanks...
 
Old 04-05-2007, 04:28 PM   #2
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
You want to check into Apache's virtual host capability. There is good documentation on the Apache site on how to set up virtual hosts.
 
Old 04-14-2007, 01:07 PM   #3
Alotau
Member
 
Registered: Jan 2005
Location: Fremont, CA
Distribution: Red Hat 9
Posts: 58

Original Poster
Rep: Reputation: 15
I've wrestled with this for a while now and can't seem to get it to work properly. The virtual hosts section of my httpd.conf file looks something like this:

Code:
Listen 80
NameVirtualHost *:80

<VirutalHost *>
  ServerName www.mydomain.com
  DirectoryIndex index.php index.html index.htm
  DocumentRoot /var/www/html/
</VirtualHost>

<VirtualHost *>
  ServerName other.mydomain.com
  DirectoryIndex index.php index.html index.htm
  DocumentRoot /home/other/public_html/
</VirtualHost>
What I have noticed in this setup is that if I switch the order of these two virtual host blocks, the site is affected. Specifically, which ever comes first controls the site: www.mydomain. com and other.mydomain.com will both use the DocumentRoot of the VirtualHost that appears first. This tells me I am definitely doing something wrong. Hopefully it's something simple... All of the examples I've seen have been for two sites like www.domain. com and www.domain2. com, I figured it shouldn't be much different, but maybe it is?

I'll gladly provide more info if it helps you help me! Thanks in advance...
 
Old 04-15-2007, 08:03 AM   #4
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
Quote:
What I have noticed in this setup is that if I switch the order of these two virtual host blocks, the site is affected. Specifically, which ever comes first controls the site:
Actually, this is correct behavior. When Apache doesn't recognize a virtual domain, it defaults to the first one in the list.

My virtual hosts directives aren't much different from yours, but there is one potentially critical difference.

You've got:

<VirtualHost *>

As your starting point, but I've got:

<VirtualHost *:80>

for all of mine.
 
Old 04-15-2007, 12:17 PM   #5
Alotau
Member
 
Registered: Jan 2005
Location: Fremont, CA
Distribution: Red Hat 9
Posts: 58

Original Poster
Rep: Reputation: 15
Well HangDog,

I took the 7 seconds to make that change, restarted the httpd, and everything worked fine. Thanks so much for noticing that little difference. Should have posted my question before trying 50 things that didn't work!
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
www not working but skype,amule kalleanka Linux - Networking 2 04-07-2007 07:58 AM
Incremental Downloading: wget http://www.mysite.org/pic[001-125].jpg fc6_user Programming 5 04-04-2007 10:25 AM
how to set permissions on /var/www? AVD_ZM Linux - Newbie 1 03-04-2007 11:27 AM
apache http://localhost/mysite ---> http://localhost/mysite/index.php how? ilnli Linux - General 8 06-04-2005 03:23 PM
cpmove-mysite.tar.gz.part10 100,020,000? lexington Linux - Newbie 3 05-10-2004 06:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:11 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration