Forum Moderators: coopster

Message Too Old, No Replies

PHP Apache virtual hosts problems

PHP Apache virtual hosts problems

         

Supernovae

3:16 pm on Mar 24, 2006 (gmt 0)

10+ Year Member



My PHP (and HTML pages when i change httpd.conf in apache; example little below) seems to prefer to goto another directory (one level up to where my other website is) instead of the one I made under virtual hosts. It seems to have something to do with this part of the httpd.conf file:

-----ScriptAlias /php/ "c:/php/"
-----AddType application/x-httpd-php .php
-----AddType application/x-httpd-php .php3
----#AddType application/x-httpd-php .htm <---
----#AddType application/x-httpd-php .html <---
-----Action application/x-httpd-php "/php/php.exe"

When i remove the # in front of the htm and html lines it also happens with my HTML pages.

Example of httpd.conf:

<VirtualHost *:80>
ServerName "www.site1.nl"
DocumentRoot "C:/site1"
</virtualhost>

<virtualHost *:80>
ServerName "www.site2.nl
DocumentRoot "C:/www/site2"
</virtualhost>

In both sites i have a phpinfo.php in the root.

When I goto www.site2.nl/phpinfo.php it will somehow take the one thats located in site1.nl (I could even remove the phpinfo.php from the site2 directory and keep up getting phpinfo from site1.nl (I cleared the cache too)

I figure is has to be something the httpd.conf file or with the php.ini but i can't figure out what it is..

PHP seems to prefer to watch at the directory I set in php.ini. (which I think I can't change because of my main website)

Supernovae

3:46 pm on Mar 24, 2006 (gmt 0)

10+ Year Member



Made a little error in the 1st vh

<VirtualHost *:80>
ServerName "www.site1.nl"
DocumentRoot "C:/<b>www</b>"
</virtualhost>

coopster

4:40 pm on Mar 24, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, Supernovae.

Looks to me as if you are trying to run PHP as CGI on a Windows server and you are thinking that the incorrect site is being pulled when you request it in the address bar because you are seeing the same phpinfo(). Well, it is likely you are indeed seeing the same php configuration info from the same php.ini file.

First, if this is indeed a correct assumption, try a simpler test. Put an index file in each of your sites DocumentRoot directories, two different index files, that will let you know which <VirtualHost> container is being used. I bet you are going to see that your config is indeed hitting the two different host containers at this point.

By the way, you are missing a quotation mark in the ServerName of your second VirtualHost container there (actually, they are unnecessary unless you have spaces in your path).

Supernovae

5:01 pm on Mar 24, 2006 (gmt 0)

10+ Year Member



NM, i just removed the doc_root = c:\site1 statement and left it empty.. now it works duh..

Supernovae

5:04 pm on Mar 24, 2006 (gmt 0)

10+ Year Member



(this command is in the php.ini btw if anyone finds the same issue in the future)