Access denied - Tried EVERYTHING
Posted by: CgullZ (---.dsl.mweb.co.za)
Date: March 20, 2013 08:52AM

I am trying to create Virtual hosts for 3 days now.

I even managed to break WAMP totally and had to reinstall it.

I read lots of tutorials and forum posts.

Nothing works !!!

PLEASE HELP ME

Windows 7, WAMP 2.2e

I have 2 local sites, ruthrudincom and thinklocal.
If I leave them both in wamp/www - ruthrudincom is working thinklocal gives me access denied.
Thinklocal is developed with codeigniter and has htaccess file.

If I move them to c:/www none is working - access denied. (I went to c:/www and gave all permissions to all users)

My files:
httpd_conf:
<Directory "c:/wamp/www/">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# [httpd.apache.org]
# for more information.
#
Options Indexes FollowSymLinks

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All

#
# Controls who can get stuff from this server.
#
# Online --> Require all granted

# onlineoffline tag - don't remove

Require local

</Directory>
<Directory "c:/www/">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>

hosts file I added these lines:
127.0.0.1 ruthrudincom.dev
127.0.0.1 thinklocal.dev

httpd_vhosts: (DocumentRoot tried with wamp and without wamp)
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot "C:/wamp/www"
ServerName localhost
ServerAlias localhost
</VirtualHost>

<VirtualHost *:80>
ServerAdmin admin@ruthrudincom.dev
DocumentRoot c:/wamp/www/ruthrudincom
ServerName ruthrudincom.dev
ErrorLog "logs/ruthrudincom.dev-error.log"
CustomLog "logs/ruthrudincom.dev-access.log" common
</VirtualHost>

#Think local
<VirtualHost *:80>
ServerAdmin admin@thinklocal.dev
DocumentRoot c:/wamp/www/thinklocal
ServerName thinklocal.dev
ErrorLog "logs/thinklocal.dev-error.log"
CustomLog "logs/thinklocal.dev-access.log" common
</VirtualHost>

The htaccess file:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
#RewriteCond $1 !^(index\.php|assets|images|robots\.txt|captcha|favicon\.ico)
#RewriteRule ^(.*)$ /thinklocal.dev/index.php/$1 [L]


# Send request via index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteRule ^(.*)$ /index.php?/$1 [L]
</IfModule>

Please, can someone help?

I evern tried installing php, mysql, apache by themeselves with no WAMP, nothing works.

Options: ReplyQuote
Re: Access denied - Tried EVERYTHING
Posted by: RiggsFolly (---.as13285.net)
Date: March 20, 2013 10:01AM

Did you read this yet?



HowTo: Create Virtual Hosts in WAMP

BEFORE DOING ANY OF THIS PLEASE ENSURE APACHE AND MYSQL ARE WORKING PROPERLY FIRST!!!


1. Create a new folder outside the wamp directory structure.
for example
C:\websites
but this can be on any disk drive visible to the PC running wamp


2. Create a subfolder in c:\websites for each site you want to create.
for example:
C:\websites\site1
C:\websites\site2


3. Edit the file C:\wamp\bin\apache\apachex.y.z\conf\extra\httpd-vhosts.conf
where x,y and z are the version numbers of apache that you actually have installed.

NOTE: If you are switching between 2 or more versions of apache this will have to be done to all your versions of apache in turn.

SUGGESTION: I like to use the format sitename.localhost to make it obvious to me that I am dealing with my localhost copy of a site, you may prefer another notation, thats ok, the word localhost has no actual defined meaning in this case, its just my way of naming my development versions of a live site.


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

	## must be first so the the wamp menu page loads when you use just localhost as the domain name
	<VirtualHost *:80>
    	DocumentRoot "C:/wamp/www"
    	ServerName localhost
    	ServerAlias localhost
    	<Directory  "D:/wamp/www">
			Order Deny,Allow
    		Deny from all
    		Allow from 127.0.0.1
			# You would never want a remote user to see this wamp config page.
		</Directory>
	</VirtualHost>


	<VirtualHost *:80>
	    DocumentRoot "C:/websites/site1"
	    ServerName site1.localhost
	    Options Indexes FollowSymLinks
	    <Directory "C:/websrc/www/site1">
			AllowOverride All
			Order Deny,Allow
			Deny from all
			Allow from 127.0.0.1
		    #If you want to allow access from your internal network
		    # For specific ip addresses add one line per ip address
		    #Allow from 192.168.0.100
	    	# For every ip in the subnet, just use the first 3 numbers of the subnet
	    	#Allow from 192.168.0
		</Directory>
	</VirtualHost>

Add as many <VirtualHost> as you require so each of your sites have one, changing the DocumentRoot, ServerName and any other of the parameters as appropriate.
This also allows you to make SITE SPECIFIC changes to the configuration.

NOTE: This will make the wamp manager "Put Online" function no longer have any effect of your sites, so leave it OFFLINE.
If you want to put one or more sites online you will have to change the Allow commands MANUALLY in this my-vhosts.conf file.

To check your subnet do the following:
Launch a command window, and run
    >ipconfig
Look for the line "Default Gateway" in the output and use the third number in your Allow commands.


4. Edit your httpd.conf file and search for these lines, they are near the bottom of the file.
# Virtual hosts
#Include conf/extra/httpd-vhosts.conf

5. Add a line under these to include your vhosts file, this will cause apache to register their existance.
Leave the origial httpd-vhosts.conf unchanged, it may serve as a useful reference if you get something wrong.
Also make a backup of this file as if you re-install or upgrade wamp it may be lost.
example:
Include conf/extra/my-vhosts.conf

6. While still editing your httpd.conf file search for
	#   onlineoffline tag - don't remove
	    Order Deny,Allow
	    Deny from all
	    Allow from 127.0.0.1

	</Directory>
DO NOT CHANGE THESE LINES!

Add the following after the <\Directory> tag

<Directory "C:/websites/">
    Order Deny,Allow
    Deny from all
    Allow from 127.0.0.1
</Directory>


This is to set security on your new directory structure so that access to these new sites is only allowed from 127.0.0.1 (localhost) and your internal network.
P.S. Your internal network will probably be something like 192.168.x.y, check your system first!


7. Now in order for your browser to know how to get to these new domain names i.e. site1.localhost and site2.localhost, we need to tell windows what IP address they are located on. There is a file called hosts that is a hangover from the days before Domain Name Servers (DNS) were invented. It is a way of giving nice easy rememberable names to IP address's, which of course is what DNS Servers do for us all now.

Edit your HOSTS file, this can be found in C:\windows\system32\drivers\etc
and is a file called "hosts", the file does not have an extension.
Windows protects this file so you must be an Administrator to be allowed to save changes to this file.

If you are using VISTA or Windows7/8 you may think you are an Administrator BUT YOU ARE NOT!!!!
So to edit this file you must launch your editor, or Notepad in a specific way to gain Administrator rights. To do this find your editors icon and launch it using the following key strokes:
Shift + Right Click over its icon, this will display a menu, click the item "Run as Administrator", and click "Allow" on the challenge dialog that will appear.

Now you are ready to edit the hosts file so navigate your editor to c:\windows\system32\drivers\etc\hosts

Add the following lines to this file

   127.0.0.1   site1.localhost
   127.0.0.1   site2.localhost
NOTE: You will need to add lines to this file for each new virtual host site you create.



8. In order for Apache to pick up these changes you must bounce apache.
Do this by: Wamp manager -> Apache -> Service -> Restart Service


You should now be able to use the address site1.localhost in your browser to get to your new sites.
Copy your sites code into the "C:/websites/xxxx" folder if you already have a site coded or,
place a quick and simple index.php file into the "c:\websites\xxxx" folder to proove it all works.

example:
   <!DOCTYPE html><html lang="en-US">
   <head>
   <meta charset="UTF-8">
   <title>SITE1</title>
   </head>
   <body>
   <?php echo '<div style="background-color:red;color;white;text-align:center;font-size:18px">HELLO FROM Site1</div>'; ?>
   </body>
   </html>



TROUBLE SHOOTING:
If you have used the new domain name ( site1.localhost ) and it has not found the site.
a. Check the changes to the hosts file.
b. Restart the "DNS Service" that runs in windows. This caches all doman names that you use in a browser so that the browser does not have to query a DNS Server each time you re-use a domain name. This may have cached your failed attempt but a restart is easy and should solve the problem and is quicker that re-booting windows, which should also work.
To do this launch a command window as an Administrator ( Shift + Left Click over the command window icon ) and run these 2 commands.

>net stop "DNS Client"
>net start "DNS Client"
Note: The quotes are required as there is a space in the services name.

Options: ReplyQuote
Re: Access denied - Tried EVERYTHING
Posted by: CgullZ (---.cpt.mweb.co.za)
Date: March 22, 2013 05:06PM

Thanks.

I followed your post but I changed this:
<VirtualHost *:80>
DocumentRoot "C:/wamp/www"
ServerName localhost
ServerAlias localhost
<Directory "D:/wamp/www"> (Don't understand why is there a D: here)

to:
<VirtualHost *:80>
DocumentRoot "C:/wamp/www"
ServerName localhost
ServerAlias localhost
<Directory "C:/wamp/www">

And changed this:
<VirtualHost *:80>
DocumentRoot "C:/websites/site1"
ServerName site1.localhost
Options Indexes FollowSymLinks
<Directory "C:/websrc/www/site1"> (not sure what is the websrc here?)

to:
<VirtualHost *:80>
DocumentRoot "C:/sites/site1"
ServerName site1.localhost
Options Indexes FollowSymLinks
<Directory "C:/sites/site1">

Now I get this error:
Forbidden

You don't have permission to access / on this server.

Options: ReplyQuote
Re: Access denied - Tried EVERYTHING
Posted by: RiggsFolly (---.as13285.net)
Date: March 22, 2013 05:15PM

Thanks for the error corrections.

If you are getting that message it is likely you have miss spelt a folder name in one of the <Directoy> sections or you have not added the ipaddress or ipaddress range of the ip you are browsing from.


First try this, use address
http://127.0.0.1/
and if that works then your issue may be an IPV4 / IPV6 issue

If it is, post again and I will send you my IPV4/IPV6 Document

Options: ReplyQuote
Re: Access denied - Tried EVERYTHING
Posted by: CgullZ (---.cpt.mweb.co.za)
Date: March 22, 2013 05:46PM

Hi there,

http://127.0.0.1/
takes me to the WAMP home page, works fine.

Thank you.



Edited 2 time(s). Last edit at 03/22/2013 05:47PM by CgullZ.

Options: ReplyQuote
Re: Access denied - Tried EVERYTHING
Posted by: RiggsFolly (---.as13285.net)
Date: March 22, 2013 07:33PM

then you need to read through this


Right, Windows as of Windows7 comes with the ability to use the IPV4 network address range and the IPV6 network address range and by default they are both turned on.
IPV4 addresses look like this: 123.321.10.234
IPV6 addresses look like this: 2001:0db8:85a3:0042:1000:8a2e:0370:7334

The IPV4 address for localhost is 127.0.0.1
The IPV6 address for localhost is ::1


See
[en.wikipedia.org]
[en.wikipedia.org]
[en.wikipedia.org]


However, Wamp's security as of now ( Feb 2013 ) is only configured to expect the IPV4 address range, but the Apache that is delivered with WAMPServer is aware of both the IPV4 and IPV6 address ranges and is happy to use either or in fact both.
I am not sure how Windows/Browsers decide which range to use but it appears to be fairly arbitrary, so you can get either.

This is the route of your problem.

There are 2 ways you can go to solve this small anomily. You can either ignore the IPV6 address range or change the security to include the IPV6 address range.


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
KEEP COPIES OF ALL FILES CHANGED SO YOU CAN EASILY UNDO THESE CHANGES IF THEY DO NOT WORK FOR YOU

In fact copy c:\wamp to a backup location and then you can just replace
the whole folder if you have problems with your changes.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


Option 1 is easier to do.
==============================================================

Option 1:
Ignore the IPV6 address range.


Use the wamp menus to edit these files where possible.

edit httpd.conf
change Listen 80 TO Listen 0.0.0.0:80
The 0.0.0.0 part tells Apache to only listen on IPV4 addresses.


edit c:\windows\system32\drivers\etc\hosts
If it exists, remove or comment out (comment is a # in colum 1) the line containing the IPV6 address for localhost >::1 localhost
(This makes the domain 'localhost' disappear from the IPV6 network, its existance is not hard coded anywhere it has to be mentioned in the hosts file to make it exists)
Make sure you have a line in the hosts file like this >127.0.0.1 localhost
(This makes the domain 'localhost' exists on the IPV4 network)

Wamps security should now work after a reboot. And
http://localhost
should now get you to wamps Apache installation. The exisiting security should also now work for phpMyAdmin,WebGrind and SQLBuddy


============================================================
Option 2:
Add the IPV6 address range to wamps security.


Again always use the wamp menus to edit these files where possible.

!!!! Make sure WAMP is set to 'Offline' before starting this part.


Now this is the dangerous bit!!!!! You must get these next 2 edits right. The text between the double quotes in C:\wamp\scripts\onlineOffline.php must match exactly that used in the httpd.conf file, so a copy and paste would be recommended. If you get this wrong the Online/Offline process will not work.

edit httpd.conf

Change
# onlineoffline tag - don't remove
Order Deny,Allow
Deny from all
Allow from 127.0.0.1

TO
# onlineoffline tag - don't remove
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 ::1

Note we have added the ::1 IPV6 localhost address to the security, make sure there is a space between 127.0.0.1 and ::1.


Edit C:\wamp\scripts\onlineOffline.php
Change

$offlineText = "# onlineoffline tag - don't remove
Order Deny,Allow
Deny from all
Allow from 127.0.0.1";

TO

$offlineText = "# onlineoffline tag - don't remove
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 ::1";

This makes sure that the Online/Offline process still works in WampServer. Make sure that this exactly matches your change above made to httpd.conf


Now edit each of the files
C:\wamp\alias\phpmyadmin.conf
C:\wamp\alias\sqlbuddy.conf
C:\wamp\alias\webgrind.conf

were ever you see >127.0.0.1 change it to >127.0.0.1 ::1
Ignore the lines that start with a #, as these are comment lines

This tells Wamp that whichever ip address from either address range you get for the domain localhost, is allowed to access the apache server.
Now whichever address range windows/browser picks for you when you use the
http://localhost
domain the security will allow you in.

edit c:\windows\system32\drivers\etc\hosts
In Windows8 you will probably see both domains in the file, but this is not guaranteed. When you are finished it should look like this.

127.0.0.1 localhost
::1 localhost

This makes the domain localhost appear on both the IPV4 and IPV6 address ranges.


When you get as far as accessing MySQL you will see that the 'root' user is configured so that it can be accesses from localhost and 127.0.0.1 and ::1 so that is all ready to go and needs no changes.

If you decide to change the password for the 'root' userid in mysql, make sure you use the same password for all the instances of root that exist in mysql. A complete MySQL userid is associated with a location, so it is not the same userid when you login from root@127.0.0.1 as when you login from root@::1. This is why there are 3 'root' userids in the default MySQL userid configiration.

Options: ReplyQuote
Re: Access denied - Tried EVERYTHING
Posted by: CgullZ (---.cpt.mweb.co.za)
Date: March 23, 2013 10:20AM

Hi,

Thank you but still no luck sad smiley

Tried both ways, didn't need to change any of the files in c:\wamp\alias

Can go to phpmyadmin, can go to local host can't go to: thinklocal.dev

My httpd.conf file looked like this:
#   onlineoffline tag - don't remove
    
    Require local

</Directory>
<Directory "C:/sites/">
	#Options Indexes FollowSymLinks
	AllowOverride all
	Order Deny,Allow
	Deny from all
	Allow from 127.0.0.1
</Directory>

Changed it to this:
#   onlineoffline tag - don't remove
    
Require local (I don't see this line in your post?)
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 ::1
</Directory>
<Directory "C:/sites/">
	#Options Indexes FollowSymLinks
	AllowOverride all
	Order Deny,Allow
	Deny from all
	Allow from 127.0.0.1 ::1
</Directory>

My hosts file looks like this:
127.0.0.1       localhost
	::1             localhost


#127.0.0.1 validation.sls.microsoft.com
127.0.0.1 thinklocal.dev

Tried this as well:
127.0.0.1 thinklocal.dev
::1 thinklocal.dev

The onlineoffline file looked like this:
$offlineText = "#   onlineoffline tag - don't remove
    Require local"; (I don't see this line in your post?)

Changed to this:
$offlineText = "#   onlineoffline tag - don't remove
    Require local
		Order Deny,Allow
Deny from all
Allow from 127.0.0.1 ::1";

Ahhhhhhhhhhhhhhhhhhhhhh



Edited 1 time(s). Last edit at 03/23/2013 10:27AM by CgullZ.

Options: ReplyQuote
Re: Access denied - Tried EVERYTHING
Posted by: CgullZ (---.cpt.mweb.co.za)
Date: March 23, 2013 10:32AM

Another thing, don't know if it means anything, going to Wireless Network Connection Properties, I see that the checkbox next to Internet Protocol Version 6 (TCP/IPv6) is not ticked.

Options: ReplyQuote
Re: Access denied - Tried EVERYTHING
Posted by: RiggsFolly (---.as13285.net)
Date: March 24, 2013 06:51PM

Looks like you have got in a bit of a mess here.

My Tutorial was written for Apache 2.2.x and it looks like you are using Apache 2.4, guess I forgot to mention that, but then so did you.

2.2 uses the form
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 ::1

2.4 uses the form
Require local

If all else fails, you could always try reading the Apache manual on the Apache webs site.

You should not allow access to C:\sites from within the httpd.conf file.
You should allow access to each vhost from within that specific VHOST definition by adding <directory> command to the VHOST definition, as per my tutorial.

Options: ReplyQuote
Re: Access denied - Tried EVERYTHING
Posted by: CgullZ (---.cpt.mweb.co.za)
Date: March 26, 2013 10:28AM

OH I feel like crying from happiness....

It works at last, Require local......

Thank you so so much for all the help.

You are a star !!!!!!

If anyone else needs to know, I removed:
<directory c:\sites>... from httpd.conf

My vhosts file looks like this:
<VirtualHost *:80>
    ServerAdmin webmaster@thinklocal.dev
    DocumentRoot c:/sites/thinklocal
    ServerName thinklocal.dev
	ServerAlias thinklocal.dev
	<Directory c:/sites/thinklocal>
		AllowOverride All
		Require local
	</Directory>
    ErrorLog "logs/thinklocal.dev-error.log"
    CustomLog "logs/thinklocal.dev-access.log" common
</VirtualHost>


My htacess
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]

HALLELUYA !!!! smiling smiley

Options: ReplyQuote
Re: Access denied - Tried EVERYTHING
Posted by: jsp254 (---.dhcp.leds.al.charter.com)
Date: April 14, 2013 07:01AM

i have a question...

in post #2 you have:
"3. Edit the file C:\wamp\bin\apache\apachex.y.z\conf\extra\httpd-vhosts.conf"

then later on you have:
"4. Edit your httpd.conf file and search for these lines, they are near the bottom of the file.
# Virtual hosts
#Include conf/extra/httpd-vhosts.conf

5. Add a line under these to include your vhosts file, this will cause apache to register their existance.
Leave the origial httpd-vhosts.conf unchanged, it may serve as a useful reference if you get something wrong.
Also make a backup of this file as if you re-install or upgrade wamp it may be lost.
example:"

do we edit httpd-vhosts.conf or not???

also i cant find my-vhosts.conf or find anywhere in post #2 that says to create it or what it should have inside it.

please elaborate or edit the original post #2

Options: ReplyQuote
Re: Access denied - Tried EVERYTHING
Posted by: CgullZ (---.cpt.mweb.co.za)
Date: April 15, 2013 07:56AM

Hi JSP254,

You either update httpd_vhosts file or you create your own vhosts file and call it whatever you want, just make sure you include it in the httpd.conf file by uncommenting this line:
#Include conf/extra/httpd-vhosts.conf

so if you update the httpd-vhosts file you will uncomment:
Include conf/extra/httpd-vhosts.conf

If you decide to create your own file, and call it bob_vhosts.conf you will have to write this line in httpd.conf:
Include conf/extra/bob_vhosts.conf.

In the bob_vhosts.conf file or the httpd_conf file you'll have this (If you are using apache 2.2.22 and your site's directory is named test):

<VirtualHost *:80>
ServerAdmin webmaster@test
DocumentRoot c:/sites/test
ServerName test
ServerAlias test
<Directory c:/sites/test>
AllowOverride All
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Directory>
ErrorLog "logs/test-error.log"
CustomLog "logs/test-access.log" common
</VirtualHost>

Hope that helps.

Options: ReplyQuote
Re: Access denied - Tried EVERYTHING
Posted by: showstopper (---.dynamic.tstt.net.tt)
Date: April 15, 2013 11:00AM

Hi most of the guide everyones giving your are correct i think you should do a spell check

Fitcom - Technology and SEO with a side of awesome

Installing and Configuring a WAMP Server in Windows 7 & 8

Options: ReplyQuote


Sorry, only registered users may post in this forum.