# apache error

## scotty026

I think i may be doing some thing stupid here but can some one help me PLEASE 

i get this error on my web site 

Forbidden

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

heres my part i put in my commonapache2.conf

<Directory /var/www/localhost/htdocs/stu>

     Options -Indexes FollowSymLinks MultiViews

     AllowOverride All

     <IfModule mod_access.c>

       Order allow,deny

       Allow from all

     </IfModule>

</Directory>

my permisions from ls -la 

drwxrw-rw-   2 root root    48 Jul 17 21:57 stu

HOW do i give out access

----------

## j4nn3

If by "access" you mean list all files in /var/www/localhost/htdocs/stu then set Options to:

```
Options +Indexes FollowSymLinks MultiViews
```

Apache doc about Indexes:

 *Quote:*   

> If a URL which maps to a directory is requested, and there is no DirectoryIndex (e.g., index.html) in that directory, then mod_autoindex will return a formatted listing of the directory.

 

One more thing (apache needs execute rights to list the directory):

```
chmod 755 /var/www/localhost/htdocs/stu
```

If you want all users to be able to write in that directory you should do something like this:

```
chmod 775 /var/www/localhost/htdocs/stu

chgroup users /var/www/localhost/htdocs/stu
```

----------

## scotty026

Ok did the following but still no luck

Options +Indexes FollowSymLinks MultiViews

chmod 755 /var/www/localhost/htdocs/stu

chgroup users /var/www/localhost/htdocs/stu

----------

## thecooptoo

tail /var/log/apache2/error_log ?

----------

## scotty026

Got the following extract from log -

Directory index forbidden by rule: /var/www/localhost/htdocs/stu/

File does not exist: /var/www/localhost/htdocs/favicon.ico

----------

## thecooptoo

ls -la  /var/www/localhost/htdocs/stu/ ?

and you did restart the server  ?

----------

## scotty026

Ye restarted server and heres my permisions

ls -la /var/www/localhost/htdocs/stu/

total 2

drwxr-xr-x  2 root users   48 Jul 17 21:57 .

drwxr-xr-x  4 root root  1816 Jul 17 21:57 ..

----------

## thecooptoo

do

```

cd /var/www/localhost/htdocs/stu/ 

nano  index.html

```

and in index.html put 

```

<html>

<body>

Hello World

</body>

</html>

```

chown stu;users index.html

chmod 755 index.html

adn then try again

----------

## scotty026

Ok cool that worked fine  :Smile:  yyippee

but how do i get my indexes showing so i can click down a folder or too

----------

## thecooptoo

So you now know that the server  is accessing the directory 

rename index.html to temp-index.html and try again . You should get a directory listing containing temp-index.html

----------

## scotty026

sorry but still comes up with 

hello world 

NO dir listings

----------

## thecooptoo

so what is  ls -la now?

do chmod 777 /var/www/localhost/htdocs/stu/ * for now

----------

## ronnie

 *scotty026 wrote:*   

> sorry but still comes up with 
> 
> hello world 
> 
> NO dir listings

 

Empty your browser cache.

----------

## scotty026

Hi guys no luck 

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

sorry for long reply been busy  :Shocked: 

here is ls -la 

drwxr-xr-x  3 root   users  104 Jul 22 02:56 .

drwxr-xr-x  4 root   root  1848 Jul 25 15:47 ..

-rwxrwxrwx  1 stuart users   43 Jul 22 02:55 temp-index.html

and ye ronnie i dumped my cache lol

----------

## thecooptoo

this wont be  agreed by everyone  

the first directive in commonapache2.conf is  *Quote:*   

> <Directory />
> 
>   Options -All -Multiviews
> 
>   AllowOverride None
> ...

 

ie deny access to everything by default and then you open up the directories as necessary . change it to 

 *Quote:*   

>  <Directory />
> 
> Options Indexes  MultiViews
> 
>   <IfModule mod_access.c>
> ...

 

and then try. If it does as you want, then your apache directory config isnt correct 

CHANGE IT BACK TO WHAT IT WAS, and then sort out the directory config

----------

## scotty026

Hi got it working  :Cool: 

now i no what to do so i can switch it on/off  :Very Happy: 

thanks alot guys this alway had me puzzled for about a year but didnt bother to fix

----------

## thecooptoo

but its much better to restore the default apache configuration and sort out what is wrong with the 

```
<....../localhost/.....stu>

Options +Indexes

</Directory>
```

bit

a less good  alternative is to have a .htaccess file  in the directory and make the apache config allowOverride Indexes (or all)

----------

## scotty026

ok thanks

if i take away the plus on  Indexes i get access but if i add the plus i dont get access so 

is this ment to do this if so cool thanks.

----------

## j-kidd

You may want to read the following presentation  :Very Happy: 

http://people.apache.org/~rbowen/presentations/apacheconEU2005/hate_apache.pdf

----------

