|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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? |
|
#2
|
||||
|
||||
|
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. |
|
#3
|
|||
|
|||
|
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. |
|
#4
|
||||
|
||||
|
Just to verify, after making any changes, you restart your server, right?
service httpd restart |
|
#5
|
|||
|
|||
|
Restart
Yes, after making every change I do:
sudo /etc/init.d/apache2 restart. |
|
#6
|
||||
|
||||
|
Quote:
Can you attach (or paste) a copy of your httpd.conf file? |
|
#7
|
|||
|
|||
|
/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> |
|
#8
|
||||
|
||||
|
Quote:
Is that all that's in your httpd.conf file? I need the whole thing, not just the virtualhost section.. |
|
#9
|
|||
|
|||
|
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.
|
|
#10
|
||||
|
||||
|
Quote:
Ok... Ubuntu dapper may actually have the config in /etc/apache2/apache2.conf |
|
#11
|
|||
|
|||
|
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 |
|
#12
|
||||
|
||||
|
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. |
|
#13
|
||||
|
||||
|
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. |