can't set up vhosts; always redirects to xampp page

Problems with the Windows version of XAMPP, questions, comments, and anything related.

can't set up vhosts; always redirects to xampp page

Postby idiotprogrammer » 10. October 2008 01:54

Instead of reading this thread, you should look at this tutorial which I wrote after experiencing the problem I described below.


How to: Setting Up Virtual hosts on Vista
viewtopic.php?p=127591#127591
*************************************

Hi, there, I installed on Vista, and I can't figure out how to do name-based hosting.

The main problem I see (which seems be different from other posters on this forum) is that http://localhost and http://read.local always redirect to the xampp website. I do not know how to stop this.

in the hosts file

Code: Select all
127.0.0.1   read.local


in httpd-vhosts.conf

Code: Select all
NameVirtualHost 127.0.0.1:80
<VirtualHost 127.0.0.1:80>

##    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "I:\My Documents\websites\read"
    ServerName read.local
ServerAlias read.local
</VirtualHost>


in httpd.conf
Code: Select all
ServerRoot "C:/apache/xampp/apache"
Listen 80
ServerName localhost:80
DocumentRoot "C:/apache/xampp/htdocs"
<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>
<Directory "C:/apache/xampp/htdocs">
    Order allow,deny
    Allow from all
</Directory>

<IfModule dir_module>
    DirectoryIndex index.php index.php4 index.php3 index.cgi index.pl index.html index.htm index.shtml index.phtml
</IfModule>
# Virtual hosts
Include conf/extra/httpd-vhosts.conf

# XAMPP specific settings
Include conf/extra/httpd-xampp.conf


I have not touched httpd-xampp.conf. Some other notes.

I can create a subdirectory under C:/apache/xampp/htdocs"
<Directory /> and access it by going to http://localhost/read
or http://read.local/read

If I rename the index.html and index.php files inside this directory, I get a directory listing.

I think I have tried all the obvious things. All except one thing. But what is it?
Last edited by idiotprogrammer on 10. October 2008 15:13, edited 3 times in total.
idiotprogrammer
 
Posts: 6
Joined: 10. October 2008 01:31
Location: Houston, TX

Postby Sharley » 10. October 2008 03:10

You are defaulting to the xampp pages because you have an issue in your setup which you may be aware of.

Lets try this and see how you go.
Windows hosts file
Code: Select all
127.0.0.1 localhost
127.0.0.1 read.local

Comment out the IPV6 entry if you have no need for it:
::1 localhost
commented out
# ::1 localhost
This will allow you to use both localhost and 127.0.0.1 in the address bar of your browser.

httpd-vhosts.conf
Code: Select all
NameVirtualHost *:80

<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/apache/xampp/htdocs"
</VirtualHost>

<VirtualHost *:80>
ServerName read.local
DocumentRoot "I:/MyDocuments/websites/read"
ServerAdmin webmaster@dummy-host2.example.com
<Directory "I:/MyDocuments/websites/read"
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>

No ServerAlias is required - a server alias is used for other names associated with the ServerName like www.server.name or forum.server.name etc.

A <Directory> directive is required as the httpd.conf defaults will restrict directory access outside of the htdocs directory.

In Vista, eliminate spaces in your directory names as permissions are tricky to set - so rename the directories as outlined in the above alternative configuration or rename to suit yourself.
Note the direction of the slashes - not \ but / in Apache conf files.

http://localhost/ - will give the XAMPP Welcome page

http://read.local/ - will give you the index page in the above DocumentRoot directory associated with the ServerName read.local.
If no index page in this directory then a file listing will be presented.

Running the command apache -S at a command prompt in C:\apache\xampp\apache\bin will return any syntax errors for you to paste here.

Good luck.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Postby idiotprogrammer » 10. October 2008 05:10

Ok, I removed some things, and tried slashes of both directions for the path. It still defaults to the default page

Code: Select all
c:\apache\xampp\apache\bin>apache -k restart

apache -t reports Syntax OK.

c:\apache\xampp\apache\bin>apache -S
VirtualHost configuration:
127.0.0.1:80           read.local (C:/apache/xampp/apache/conf/extra/httpd-v
hosts.conf:51)
wildcard NameVirtualHosts and _default_ servers:
_default_:443          localhost (C:/apache/xampp/apache/conf/extra/httpd-ssl.co
nf:74)
*:80                   is a NameVirtualHost
         default server localhost (C:/apache/xampp/apache/conf/extra/httpd-vhost
s.conf:63)
         port 80 namevhost localhost (C:/apache/xampp/apache/conf/extra/httpd-vh
osts.conf:63)
         port 80 namevhost read.local (C:/apache/xampp/apache/conf/extra/htt
pd-vhosts.conf:69)
Syntax OK

c:\apache\xampp\apache\bin>



Code: Select all
127.0.0.1       localhost
#::1             localhost
127.0.0.1   teleread.local


I see this error message
Code: Select all
[Thu Oct 09 23:00:06 2008] [error] [client 127.0.0.1] client denied by server configuration: C:/apache/xampp/contrib
[Thu Oct 09 23:00:06 2008] [error] [client 127.0.0.1] client denied by server configuration: C:/apache/xampp/contrib
[Thu Oct 09 23:00:06 2008] [error] [client 127.0.0.1] client denied by server configuration: C:/apache/xampp/contrib
[Thu Oct 09 23:00:06 2008] [error] [client 127.0.0.1] client denied by server configuration: C:/apache/xampp/contrib
[Thu Oct 09 23:00:06 2008] [error] [client 127.0.0.1] client denied by server configuration: C:/apache/xampp/contrib


Here is my revised virtual host config:

Code: Select all
NameVirtualHost *:80

<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/apache/xampp/htdocs"
</VirtualHost>


<VirtualHost *:80>
ServerName read.local
DocumentRoot "I:/My Documents/websites/read"
ServerAdmin webmaster@dummy-host2.example.com
<Directory "I:/My Documents/websites/read">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
idiotprogrammer
 
Posts: 6
Joined: 10. October 2008 01:31
Location: Houston, TX

Postby Sharley » 10. October 2008 06:11

The slashes can only be as I suggested.

127.0.0.1 localhost
#::1 localhost
127.0.0.1 teleread.local
I don't see
127.0.0.1 read.local
which is obviously different to
127.0.0.1 teleread.local

Your still using spaces in your directory names which on Vista, when using Apache, will cause issues with access permissions as I pointed out above.

After making changes to the conf files you must restart apache to have those changes initiated.
These should be the only entries in the vhosts file at the moment:
Code: Select all
NameVirtualHost *:80

<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/apache/xampp/htdocs"
</VirtualHost>

<VirtualHost *:80>
ServerName read.local
DocumentRoot "I:/MyDocuments/websites/read"
ServerAdmin webmaster@dummy-host2.example.com
<Directory "I:/MyDocuments/websites/read"
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>

If your hosts file is correct and you use the above vhosts entries only then it should work.
However if not we can look at an alternative.

BTW your results for apache -S have been sorted for better understanding here:
Code: Select all
VirtualHost configuration:

127.0.0.1:80 read.local (C:/apache/xampp/apache/conf/extra/httpd-vhosts.conf:51)

wildcard NameVirtualHosts and _default_ servers:

_default_:443 localhost (C:/apache/xampp/apache/conf/extra/httpd-ssl.conf:74)

*:80 is a NameVirtualHost

default server localhost (C:/apache/xampp/apache/conf/extra/httpd-vhosts.conf:63)

port 80 namevhost localhost (C:/apache/xampp/apache/conf/extra/httpd-vhosts.conf:63)
port 80 namevhost read.local (C:/apache/xampp/apache/conf/extra/httpd-vhosts.conf:69)

Syntax OK

The first line is telling me you still have that entry 127.0.0.1:80 read.local in the vhosts file - how about only having those entries I pasted here and correct the folder name without the spaces and see how you go.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Postby idiotprogrammer » 10. October 2008 11:44

Ok, a few things,

I closed the directory tag from your example

Code: Select all
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/apache/xampp/htdocs"
</VirtualHost>

<VirtualHost *:80>
ServerName read.local
DocumentRoot "I:/My Documents/websites/read"
ServerAdmin webmaster@dummy-host2.example.com
<Directory "I:/MyDocuments/websites/read">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>


and here's the host file


Code: Select all
127.0.0.1       localhost
#::1             localhost
127.0.0.1   read.local


Please note that in httpd.conf I did not modify anything so I see:

DocumentRoot "C:/apache/xampp/htdocs"


apache -S

Code: Select all
c:\apache\xampp\apache\bin>apache -S

VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
_default_:443          localhost (C:/apache/xampp/apache/conf/extra/httpd-ssl.conf:74)

*:80                   is a NameVirtualHost
default server localhost (C:/apache/xampp/apache/conf/extra/httpd-vhost
s.conf:63)

port 80 namevhost localhost (C:/apache/xampp/apache/conf/extra/httpd-hosts.conf:63)
       
port 80 namevhost read.local (C:/apache/xampp/apache/conf/extra/httpd-vhosts.conf:69)
Syntax OK

c:\apache\xampp\apache\bin>


Other ideas?
idiotprogrammer
 
Posts: 6
Joined: 10. October 2008 01:31
Location: Houston, TX

Postby idiotprogrammer » 10. October 2008 11:46

2 other things.

To restart apache, I try


apache -k restart

I do in fact clear my cache when I retry (both in IE and Firefox).
idiotprogrammer
 
Posts: 6
Joined: 10. October 2008 01:31
Location: Houston, TX

Postby idiotprogrammer » 10. October 2008 12:03

Ok, here is something really interesting.

I also set the Loglevel to Debug in httpd.conf and I see this ..



c:\apache\xampp\apache\bin>apache -k stop
(OS 5)Access is denied. : Failed to open the Apache2.2 Service

c:\apache\xampp\apache\bin>

That tells me that when I've been running apache -k restart , the apache service has not in fact been restarting. (so it has never been reading my server corrections). So it seems we have an issue with windows vista, not with the configuration file.

I should note that my XAmp control panel doesn't seem to do anything if I press Stop

Just for the hell of it, I'm going to restart Vista and see what happens. But I'm not going to make a habit of this :)

So I need to know how to restart apache in Vista 64 bit and how to verify that I have restarted successfully.
idiotprogrammer
 
Posts: 6
Joined: 10. October 2008 01:31
Location: Houston, TX

Postby Sharley » 10. October 2008 13:00

That tells me that when I've been running apache -k restart , the apache service has not in fact been restarting...

.\xampp\readme_en.txt wrote:* Apache Notes:

(1) In contrast of apache 1.x, you can not stop the apache 2.x with the command "apache -k shutdown". These functions only for an installations as service by NT systems.
Usually people read these files as a matter of course also try the FAQ for more useful basic information about XAMPP and it's components.

Try using the apache_start.bat and apache_stop.bat files until you get the hang of using the CP - the services bat files are in the apache directory and the mysql directory respectively.

In Vista right click on the file you wish to run and select run as administrator or some some rubbish.

I have not down graded to Vista so your on your own or wait till some one else who has and who may be able to help with Vista specific quirks reads your thread.

You see, I am not even sure that XAMPP and it's exe files and bat files are even 64 bit compatible.

This from the XAMPP compatibility list:
Code: Select all
Windows comatibility list (win32), here tests for version 1.6.8

Windows 2000 (w2k):       server test okay
Windows Server 2003 R2:    server test okay
Windows XP Service Pack 2:    server test okay
VISTA Ultimate:       server test okay
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Postby w4vy » 10. October 2008 13:15

is there a file inside htdocs folder called Index.php ? or your vhost folder ? If so open it with your fav text editor and if it has this code in it then delete it or move it to another folder for safe keeping :-

Code: Select all
<?php
   if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) {
      $uri = 'https://';
   } else {
      $uri = 'http://';
   }
   $uri .= $_SERVER['HTTP_HOST'];
   header('Location: '.$uri.'/xampp/');
   exit;
?>
Something is wrong with the XAMPP installation :-(


IF you did find that code in that file then that is why you are being taken to the xampp start-up page as the code is a redirect script.

Hope that helped you a little.

w4vy


EDIT: Your issue with the xampp controll panel is because you have to start it with full permissions via Right click "Run as Admin" and then you will find it will work perfect for you.
Image
User avatar
w4vy
 
Posts: 153
Joined: 04. June 2008 09:58
Location: England


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 79 guests