Apache Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationApache Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old April 26th, 2008, 12:52 PM
vital101 vital101 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 26 vital101 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 53 m 20 sec
Reputation Power: 0
general - Virtual Hosts Problem

I'm trying to configure virtual hosts on my Linux Box (using Apache2). My httpd.conf files looks like:
Code:
 
<VirtualHost *>
    ServerName www.thedevforum.com
    DocumentRoot /var/www/phpBB3
</VirtualHost>

<VirtualHost *>
    ServerName 192.168.1.101
    DocumentRoot /var/www
</VirtualHost>

<VirtualHost *>
    ServerName 24.180.255.54
    DocumentRoot /var/www
</VirtualHost>

<VirtualHost *>
    ServerName www.re-cycledair.com
    DocumentRoot /var/www/wordpress
</VirtualHost>


My problem is that thedevforum.com gets directed to the correct place. As do the ip address, however re-cycledair get's redirected to the same place as thedevforum.

Am I configuring this wrong?

Reply With Quote
  #2  
Old April 26th, 2008, 03:31 PM
hiker's Avatar
hiker hiker is offline
They're coming to take me away
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2005
Location: Florida
Posts: 2,791 hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)  Folding Points: 33832 Folding Title: Starter FolderFolding Points: 33832 Folding Title: Starter Folder
Time spent in forums: 1 Month 1 Week 4 Days 2 h 9 m 58 sec
Reputation Power: 1207
Try something like:

NameVirtualHost 192.168.1.101:80

<VirtualHost 192.168.1.101:80>
ServerName thedevforum.com
ServerAlias www.thedevforum.com
DocumentRoot /var/www/phpBB3
</VirtualHost>

<VirtualHost 192.168.1.101:80>
ServerName re-cycledair.com
ServerAlias www.re-cycledair.com
DocumentRoot /var/www/wordpress
</VirtualHost>

You don't need to declare the IP addresses as virtualhosts.

And make sure port 80 is forwarded in the router and opened in any firewalls. (If your ISP blocks port 80, then change the port number in your httpd.conf to another port for the Listen directive as well.

Reply With Quote
  #3  
Old April 26th, 2008, 03:53 PM
vital101 vital101 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 26 vital101 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 53 m 20 sec
Reputation Power: 0
Nope.

Following your advice, my httpd.conf file now looks like:
Code:
 
 This is here for backwards compatability reasons and to support
#  installing 3rd party modules directly via apxs2, rather than
#  through the /etc/apache2/mods-{available,enabled} mechanism.
#
#LoadModule mod_placeholder /usr/lib/apache2/modules/mod_placeholder.so

NameVirtualHost 192.168.1.101:80
<VirtualHost 192.168.1.101:80>
    ServerName thedevforum.com
    ServerAlias www.thedevforum.com
    DocumentRoot /var/www/phpBB3
</VirtualHost>

<VirtualHost 192.168.1.101:80>
    ServerName re-cycledair.com
    ServerAlias www.re-cycledair.com
    DocumentRoot /var/www/wordpress
</VirtualHost>


When I go to http://www.thedevforum.com, I get /var/www/phpBB3.
Anything else though (192.168.1.101, 24.180.255.54, re-cycledair.com), and I'm being put through to /var/www/phpBB3. I really can't think of any reason why it would be doing this.

For the record, I'm running Ubuntu Dapper with Apache2.

Reply With Quote
  #4  
Old April 26th, 2008, 06:13 PM
hiker's Avatar
hiker hiker is offline
They're coming to take me away
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2005
Location: Florida
Posts: 2,791 hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)  Folding Points: 33832 Folding Title: Starter FolderFolding Points: 33832 Folding Title: Starter Folder
Time spent in forums: 1 Month 1 Week 4 Days 2 h 9 m 58 sec
Reputation Power: 1207
Just to verify, after making any changes, you restart your server, right?

service httpd restart

Reply With Quote
  #5  
Old April 26th, 2008, 06:41 PM
vital101 vital101 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 26 vital101 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 53 m 20 sec
Reputation Power: 0
Restart

Yes, after making every change I do:
sudo /etc/init.d/apache2 restart.

Reply With Quote
  #6  
Old April 26th, 2008, 09:37 PM
hiker's Avatar
hiker hiker is offline
They're coming to take me away
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2005
Location: Florida
Posts: 2,791 hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)  Folding Points: 33832 Folding Title: Starter FolderFolding Points: 33832 Folding Title: Starter Folder
Time spent in forums: 1 Month 1 Week 4 Days 2 h 9 m 58 sec
Reputation Power: 1207
Quote:
Originally Posted by vital101
Yes, after making every change I do:
sudo /etc/init.d/apache2 restart.


Can you attach (or paste) a copy of your httpd.conf file?

Reply With Quote
  #7  
Old April 26th, 2008, 09:42 PM
vital101 vital101 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 26 vital101 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 53 m 20 sec
Reputation Power: 0
/etc/apache2/httpd.conf


NameVirtualHost 192.168.1.101:80

<VirtualHost 192.168.1.101:80>
ServerName thedevforum.com
ServerAlias www.thedevforum.com
DocumentRoot /var/www/phpBB3
</VirtualHost>

<VirtualHost 192.168.1.101:80>
ServerName re-cycledair.com
ServerAlias www.re-cycledair.com
DocumentRoot /var/www/wordpress
</VirtualHost>

Reply With Quote
  #8  
Old April 26th, 2008, 09:53 PM
hiker's Avatar
hiker hiker is offline
They're coming to take me away
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2005
Location: Florida
Posts: 2,791 hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)  Folding Points: 33832 Folding Title: Starter FolderFolding Points: 33832 Folding Title: Starter Folder
Time spent in forums: 1 Month 1 Week 4 Days 2 h 9 m 58 sec
Reputation Power: 1207
Quote:
Originally Posted by vital101
/etc/apache2/httpd.conf


NameVirtualHost 192.168.1.101:80

<VirtualHost 192.168.1.101:80>
ServerName thedevforum.com
ServerAlias www.thedevforum.com
DocumentRoot /var/www/phpBB3
</VirtualHost>

<VirtualHost 192.168.1.101:80>
ServerName re-cycledair.com
ServerAlias www.re-cycledair.com
DocumentRoot /var/www/wordpress
</VirtualHost>


Is that all that's in your httpd.conf file? I need the whole thing, not just the virtualhost section..

Reply With Quote
  #9  
Old April 26th, 2008, 09:56 PM
vital101 vital101 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 26 vital101 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 53 m 20 sec
Reputation Power: 0
Really, that's the whole thing. I'm VERY new to hosting web sites. Previously I just did "apt-get install apache2" and went to work. Any configuration past that I never did. So yeah, that's it.

Reply With Quote
  #10  
Old April 26th, 2008, 09:59 PM
hiker's Avatar
hiker hiker is offline
They're coming to take me away
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2005
Location: Florida
Posts: 2,791 hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)  Folding Points: 33832 Folding Title: Starter FolderFolding Points: 33832 Folding Title: Starter Folder
Time spent in forums: 1 Month 1 Week 4 Days 2 h 9 m 58 sec
Reputation Power: 1207
Quote:
Originally Posted by vital101
Really, that's the whole thing. I'm VERY new to hosting web sites. Previously I just did "apt-get install apache2" and went to work. Any configuration past that I never did. So yeah, that's it.


Ok... Ubuntu dapper may actually have the config in /etc/apache2/apache2.conf

Reply With Quote
  #11  
Old April 27th, 2008, 11:39 AM
vital101 vital101 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 26 vital101 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 53 m 20 sec
Reputation Power: 0
Considering that, it made no difference at all. I also tried going the Webmin route, and creating my virtual servers through that utility. That didn't work either. I also tried adding config files to the site-available folder, then using a2ensite <mysite> to enable them. I restarted apache and got nothing. I'm really out of ideas. I've tried pretty much everything I've found on the internet, and I seem to be the only one who can't get it to work.

I've also re-installed apache and all modules and that didn't help either. I also made sure to nuke the config files (just to make sure). Anymore ideas? Or perhaps some example configurations (including httpd.conf, apache.conf, sites-enables, etc).

Thanks,
vital101

Reply With Quote
  #12  
Old April 27th, 2008, 12:07 PM
hiker's Avatar
hiker hiker is offline
They're coming to take me away
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2005
Location: Florida
Posts: 2,791 hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)hiker User rank is General 4th Grade (Above 100000 Reputation Level)  Folding Points: 33832 Folding Title: Starter FolderFolding Points: 33832 Folding Title: Starter Folder
Time spent in forums: 1 Month 1 Week 4 Days 2 h 9 m 58 sec
Reputation Power: 1207
If you're going to go the Webmin route, I would install Virtualmin and use that to configure the domains.

However, go ahead and paste (or attach) your apache2.conf file.

Reply With Quote
  #13  
Old April 28th, 2008, 11:38 AM
jharnois's Avatar
jharnois jharnois is offline
mod_dev_shed
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Sep 2002
Location: Atlanta, GA
Posts: 14,282 jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 2 Days 16 m 26 sec
Reputation Power: 744
If the domain requested does not match a <VirtualHost>, Apache uses the first one, so it's a good idea to make a <VirtualHost> equal to the main server config. I believe this is required in Apache 2 if you want to use the main server config.

Changing to the IP address in the <VirtualHost> as hiker suggested is causing re-cycledair.com to not match because its IP address is 24.180.255.54 and you're using 192.168.1.101.

I only recommend specifying IPs in <VirtualHost>s if you have multiple IPs.

So, based on setting the default first and not using IPs, I'd have:
Code:
NameVirtualHost *

<VirtualHost *>
  DocumentRoot /var/www
</VirtualHost>

<VirtualHost *>
  ServerName thedevforum.com
  ServerAlias www.thedevforum.com
  DocumentRoot /var/www/phpBB3
</VirtualHost>

<VirtualHost *>
  ServerName re-cycledair.com
  ServerAlias www.re-cycledair.com
  DocumentRoot /var/www/wordpress
</VirtualHost>
__________________
# Jeremy

Explain your problem instead of asking how to do what you decided was the solution.

Reply With Quote