You don't have permission to access / on this server
Posted by: billtepe (---.dhcp.insightbb.com)
Date: May 03, 2012 07:19PM

Hi,

I need to get my WAMP server to behave in terms of the root just as it would when hosted on a public site... For testing purposes. I have Windows 7 Home Premium for OS.

I found this post telling how to set up vhost, [forum.wampserver.com] which sounds like exactly what I need. After following all instructions contained in it I continue to get 403 Forbidden.

Wamp icon is green and online.

I have this in my httpd.conf file:

# Virtual hosts
# Bill uncommented out this line on 5-2-12
Include conf/extra/httpd-vhosts.conf

This is the contents of my httpd-vhosts.conf file located in the conf\extra folder


#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:[httpd.apache.org];
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
ServerAdmin webmaster@.localhost
DocumentRoot "c:/wamp/www"
ServerName localhost
ServerAlias localhost
# ErrorLog "logs/dummy-host.example.com-error.log"
# CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>

<VirtualHost *:80>
ServerAdmin webmaster@stp.localserver
DocumentRoot "c:/web_sites/www/stp"
ServerName stp.localserver
ServerAlias stp.localserver
# ErrorLog "logs/dummy-host2.example.com-error.log"
# CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>

#<VirtualHost *:80>
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot "c:/Apache2/docs/dummy-host.example.com"
# ServerName dummy-host.example.com
# ServerAlias www.dummy-host.example.com
# ErrorLog "logs/dummy-host.example.com-error.log"
# CustomLog "logs/dummy-host.example.com-access.log" common
#</VirtualHost>

#<VirtualHost *:80>
# ServerAdmin webmaster@dummy-host2.example.com
# DocumentRoot "c:/Apache2/docs/dummy-host2.example.com"
# ServerName dummy-host2.example.com
# ErrorLog "logs/dummy-host2.example.com-error.log"
# CustomLog "logs/dummy-host2.example.com-access.log" common
#</VirtualHost>

This is my windows hosts files:

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host

127.0.0.1 localhost
192.168.1.200 stp.localserver

Here is the small index.php file that is the only thing in the c:\web_sites\stp folder:

<html>
<head><title>PHP Test</title></head>
<body><?php echo '<p>Hello World</p>'; ?></body>
</html>

I have stopped all WAMP Services. then I have restarted the DNS-Client service, then restarted WAMP services.

I have read for hours through other posts and tried a myriad of things all to no avail. Any help is greatly appreciated.

Thanks, Bill



Edited 1 time(s). Last edit at 05/03/2012 08:32PM by billtepe.

Options: ReplyQuote
Re: You don't have permission to access / on this server
Posted by: RiggsFolly (---.as13285.net)
Date: May 03, 2012 08:39PM

Bill,

Ok your HOSTS file is like a local DNS server and defines the situation to the machine it lives on. So change it as follows:

127.0.0.1 localhost
127.0.0.1 stp.localserver

My humble suggestion is to move your sites out of the wamp/www folder so if you ever upgrade wamp you just need to save your Include conf/extra/httpd-vhosts.conf and you can restore it on the new version and your 'good to go'

so lets assume you move your sites to a directory called c:\www\stp

So now change your Include conf/extra/httpd-vhosts.conf to this

## must be first so the the wamp menu page loads
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot "C:/wamp/www"
ServerName localhost
ServerAlias localhost
</VirtualHost>

# my first site
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot "C:/www/stp"
ServerName stp.localhost
ServerAlias stp.localhost
</VirtualHost>



now in your httpd.conf find this section
# onlineoffline tag - don't remove
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
---------------------------------------

and to allow access to this new folder add this section


# All our testing source goes in here now
<Directory "D:/www/">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
# to allow access from my local network add this line so other PC on my network are allowed in but not anything from the internet
Allow from 192.168.2
# If you want the world to be allowed in uncomment this line
# allow from all
</Directory>



I hope you can follow this and extrapolate it to your specific requirement. But this allows me to copy files from my test folders directly to my live servers.

Each time you add another project add another folder to c:\www and add a section to the onf/extra/httpd-vhosts.conf to give it a name etc so apache can find your site.

Options: ReplyQuote
Re: You don't have permission to access / on this server
Posted by: billtepe (---.dhcp.insightbb.com)
Date: May 03, 2012 10:11PM

Hi,

I made the changes you described. Now I'm getting a page whose source is as follows. I tried to paste a small screen shot, but I guess no graphics in forum??

In the address bar of Firefox I type: stp.localhost. and get the page. Essentially saying "Index of /" along with what appears to be headers for file name type info. Can you tell me what might be going on here? Thanks so much for your help.

Bill


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<title>Index of /</title>
</head>
<body>
<h1>Index of /</h1>
<table><tr><th><img src="/icons/blank.gif" alt="[ICO]"></th><th><a href="?C=N;O=D">Name</a></th><th><a href="?C=M;O=A">Last modified</a></th><th><a href="?C=S;O=A">Size</a></th><th><a href="?C=D;O=A">Description</a></th></tr><tr><th colspan="5"><hr></th></tr>
<tr><th colspan="5"><hr></th></tr>
</table>
</body></html>

Options: ReplyQuote
Re: You don't have permission to access / on this server
Posted by: billtepe (---.dhcp.insightbb.com)
Date: May 03, 2012 10:31PM

OK.. duh!!

In my haze of testing I had deleted the index.php file from the folder to see if I could get the server to give me a message other than No Access.

I put the index.php file back in and it seems to be working now.

Thanks a bunch!!!

Bill

Options: ReplyQuote


Sorry, only registered users may post in this forum.