Jump to content


Photo

Virtual Host Problems


  • Please log in to reply
3 replies to this topic

#1 sadkinso

sadkinso
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 26 October 2006 - 05:22 AM

So I've read the documentation, tested, changed settings, anything I could think of, and I still can't get this to work.

I'm running Apache 2.2.2 and want to host two sites on one IP address.  I set up the virtual hosts as follows:


listen 80

NameVirtualHost *:80

<VirtualHost *:80>
#backup page
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"
ServerName localhost
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "C:/www/TheAccessoryOutlet"
ServerName 127.0.0.1
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "C:/www/BeadsByDee"
ServerName 192.168.0.41
</VirtualHost>


I know the ServerNames are funny, but I'll explain why that's okay in a sec.

I have the first host (in htdocs) as the default backup host with a "index.php" that just says try again, or whatever.  The next two have "index.php" in their respective folders.  The problem I'm having is that the backup is the page loading everytime, no matter what ServerName I access my server with.

Naturally, I just thought it was always going to the backup page because my ServerNames weren't matching since I'm not using actual URLs, just IP addresses, but I decided to print out $_SERVER['DOCUMENT_ROOT'], and it accurately identifies the corresponding doc root that I wanted.  Namely, I get a different doc root for going through localhost, 127.0.0.1, or 192.168.0.41, as if they were URLs, as I intended.

So why, then, is it loading up the first "index.php", when it says explicitly that the doc root is otherwise?  I even put an identically named image in each folder, and it loaded different ones up each time, but still would say "try again", since it loaded the backup "index.php".  What the heck is going on?

Does anyone have some insight?  I need it to load up the respective "index.php".  Maybe I can redirect it or something?

#2 thesurfer31

thesurfer31
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 28 October 2006 - 08:25 AM

Hej,

I am running virtual hosts on my Apache 2.0 running in Windows XP.  further, I have a dynamic IP address which doesn't change very often so I have 'hard coded' it in as this is a private server.  I also had some trouble setting up virtual hosts but it has been working for a year now.

My httpd.conf file for virtual hosts looks like below, perhaps this will give you some ideas?

-----------------------BEGIN HTTPD.CONF VIRTUAL HOSTS SEGMENT --------------------

<VirtualHost 85.226.70.148:80>
    ServerName www.multisolutions.mine.nu   
    DocumentRoot htdocs/multisolutions
    ServerAdmin randal.vincelette@bredband.net
    ErrorLog logs/multisolutions.mine.nu-error_log
    CustomLog logs/multisolutions.mine.nu-access_log common
</VirtualHost>
<VirtualHost 85.226.70.148:80>
    ServerName www.arikeinanen.mine.nu
    DocumentRoot htdocs/arikeinanen
    ServerAdmin randal.vincelette@bredband.net
    ErrorLog logs/arikeinanen.mine.nu-error_log
    CustomLog logs/arikeinanen.mine.nu-access_log common
</VirtualHost>

#3 sadkinso

sadkinso
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 29 October 2006 - 07:55 AM

I tried some differences from your configuration and my configuration, but no luck.  I'm going to try reinstalling the software, as this problem simply baffles me.

#4 sadkinso

sadkinso
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 30 October 2006 - 03:48 AM

Okay, I figured out the problem.  It was because I was running PHP as a CGI, not a module, so that when the scripts would parse in the PHP engine, it would spit them back out at the document root that you set in PHP.ini, and not in the document root of your server.

It only took me about 6 hours, but hopefully no one else has to go though this.

Happy hosting.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users