# Apache and DocumentRoot

## joefish

[ OK, so there's heaps of threads on this in these forums, but reading those I sitll can't get this to work. ]

I'm running Apache (1.3.33), and I've changed my documentroot setting, so that line in apache.conf reads:

```
DocumentRoot /home/www/localhost/htdocs
```

My problem is that when I try to access my website, I get

 *Quote:*   

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

 

Now, I'm not using vhosts at all, so the vhost conf files are not included in the main apache.conf (the lines to include them are commented out).

My commonapache.conf used to read:

```
...

<Directory />

  Options -All -Multiviews

  AllowOverride None

  Order deny,allow

  Deny from all

</Directory>

...

```

But after reading some other posts, I changed this part to:

```
<Directory /home/www/localhost/htdocs>

  Options -All -Multiviews

  AllowOverride None

  Order deny,allow

  Deny from all

</Directory>
```

I still get the error however. The directory (and it's parents) have the permissions 755. It probably doesn't make any difference, but 'home' is a seperate partition on my HD.

Yes, I did restart apache after making the changes!

----------

## Nossie

Hi,

Do you have any files in /home/www/localhost/htdocs ?

----------

## thecooptoo

to see if its an apache config permissions problem 

```
<Directory />

 Options -Indexes Multiviews ExecCGI

Options +FollowSymlinks

AllowOverride All

  <IfModule mod_access.c>

    Order deny,allow

         Allow from all

  </IfModule>

```

will open it up to everything. if this works  then its an apache permssions problem .

Once its working tighten  up the permissions

----------

## daftadam

The 

```
<Directory />
```

 part should be left alone, so the default is to deny access.

Instead you should make another entry (isn't it already there in the default config ?!?) for the defaultroot directory and change "deny from all" to "allow from all"

----------

## joefish

Thanks for your help guys. I did what you said daftadam, that does seem to make sense.

So now my commonapache.conf has two entries:

```
<Directory />

  Options -All -Multiviews

  AllowOverride None

  Order deny,allow

  Deny from all

</Directory>

<Directory /home/www/localhost/htdocs>

  Options -All -Multiviews

  AllowOverride None

  Order deny,allow

  Allow from all

</Directory>
```

 *Quote:*   

> isn't it already there in the default config ?!?

 

Nope. Maybe they expext you to use virtual hosts? That's what I've always done in the past.

----------

## Rüpel

Does it help if you change Order deny,allow the other way around? Order allow,deny?

----------

## joefish

No, that doesn't appear to make a difference. But I have it working with daftadam's solution anyway.

I really should read the apache manual so I actually understand what I'm doing a bit more  :Laughing: 

----------

## mgordon

Hey!

This seems a pretty closely related thread... Can any1 tell me how to do multiple namebased vhosts with different document roots? I've added following to vhosts.conf:

```
NameVirtualHost *:80

<VirtualHost *:80>

ServerName workspace

DocumentRoot /home/max/public_html

CustomLog logs/max common

</VirtualHost>

<VirtualHost *:80>

ServerName myadmin

DocumentRoot /var/www/localhost/htdocs/phpmyadmin

CustomLog logs/myadmin common

</VirtualHost>
```

And in the hosts file I added:

```
127.0.0.1 localhost mycompname workspace myadmin
```

Why do I always end up at the apache start page no matter which address I provide  :Confused: 

----------

## thecooptoo

is the include vhosts.conf line uncommented in commonapache2.conf ?

restarted the server?

document root fiesl exist ?

any help from tail /var/log/apache2/access_log and error_log

----------

## mgordon

Ok, it seems the Include vhosts.conf is located in apache2.conf and not commonapache2.conf. Unfortunately uncommenting it didnt help...

I've checked the logs and only found complaints about favicon....

The error log seems to look in the right directories though...

Myadmin:

[Sat Mar 12 12:30:16 2005] [error] [client 127.0.0.1] File does not exist: /var/www/localhost/htdocs/phpmyadmin/favicon.ico

Workspace:

[Sat Mar 12 12:30:19 2005] [error] [client 127.0.0.1] File does not exist: /home/max/public_html/favicon.ico

I've restarted the server after every change...

----------

## thecooptoo

do cat ..../....vhosts.conf |grep -v '#'

and lets have a look

----------

## mgordon

cat /etc/apache2/conf/vhosts/vhosts.conf|grep -v '#'

```
NameVirtualHost *:80

<VirtualHost *:80>

ServerName workspace

DocumentRoot /home/max/public_html

CustomLog logs/max common

</VirtualHost>

<VirtualHost *:80>

ServerName myadmin

DocumentRoot /var/www/localhost/htdocs/phpmyadmin

CustomLog logs/myadmin common

</VirtualHost>
```

And also the dirs:

 *Quote:*   

>  ~ $ ls -ld /home/max/public_html/
> 
> drwxr-xr-x  4 max users 4096 12 mar 12.37 /home/max/public_html/
> 
> 

 

 *Quote:*   

> ~ $ ls -ld /var/www/localhost/htdocs/phpmyadmin/
> 
> drwxr-xr-x  7 root root 4096  8 mar 21.45 /var/www/localhost/htdocs/phpmyadmin/

 

Thanks by the way for helping me out here  :Smile: 

----------

## daftadam

You need to set the apache to use the name supplied by the client with:

```
UseCanonicalName Off
```

in commonapache2.conf (or the vhosts.conf)

BTW name-based virtual hosts don't work with SSL due to the nature of the protocol...which sux a bit  :Wink: 

----------

## mgordon

Thanks, got it working.  :Very Happy: 

----------

