Problem with local apache server!

Hey guys,

I’m having trouble with my local Apache server. I installed a local Apache server called “Uniform Server” and when i start the server it takes me to the index page but i get an error. Also im running the latest version which at this time is 7.0.4.


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

this happens only when i type in localhost in the URL bar. When i type it takes me to the index page with no problems.

I checked the .httaccess file and these are the settings:

# Server root folder www .htaccess
# This file provides server security limiting access to the localhost only.
# Comment next three lines to deactivate. (Allows external access)

Order Deny,Allow
Deny from all
Allow from localhost

# To allow execution of cgi scripts in this directory uncomment next two lines.

AddHandler cgi-script .pl .cgi
Options +ExecCGI +FollowSymLinks

# Activate this section to use the Private Server Feature!
# Defaults: Username - root; Password - root
# Note AuthUserFile: File path is relative to server root
# To lock server, uncomment the next 4 lines. (A name and password is required)

#AuthName "Uniform Server - Server Access"
#AuthType Basic
#AuthUserFile ../../../htpasswd/www/.htpasswd
#Require valid-user

This is weird because i don’t get why localhost doesn’t work but if i type in the IP address of any file on the local web-server like

It works.

But If i type this:


It doesn’t work. This happens with any file or folder im trying to access.

In the Apache manual on the allow directive it says

mod_authz_host - Apache HTTP Server

So maybe the reverse DNS lookup on your PC doesn’t return localhost (but something else), in which case the allow would indeed fail and deny you access.

I am not positive about this reply because apache is not really my strongest card, but nobody else has piped up so here goes;

If you are running windows did you check your local hosts file?

(W2k3 server it is kept at: C:\windows\system32\Drivers\etc\hosts)

It should contain at least this line       localhost

I hope that this advice helps, but it may only be true of my version of win32, search your hdd for the file ‘hosts’ and see if exists.

As an aside you can then append more lines to your hosts file.       <insert-any-other-test-website-here>

For example, all my snippets, workouts, tests etc are kept if a folder called ‘/code’ so I have this line in my hosts file:       code

I also have the corresponding instructions in my apache httpd.conf file:

<VirtualHost *:80>
DocumentRoot /var/www/html/code
ServerName code
DirectoryIndex index.php
#CustomLog logs/access_log combined

You may need to restart Apache if you alter your httpd.conf file.

I just checked my hosts files under windows 7, here are the results:

# 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:
#          # source server
#              # x client host

# localhost name resolution is handled within DNS itself.       localhost
	::1             localhost

I don’t know if this is right, but it looks OK.