newbie: why is Apache still going to default site?

newbie: why is Apache still going to default site?

am 03.09.2007 21:44:55 von deko

I just installed Apache2 on Debian. I added a site called test and enabled it
(a2ensite test) and disabled the default site (a2dissite default).

When I browse http://myserver I get an error:

The requested URL /apache2-default/ was not found on this server.

I've cleared my browser's cache and rebooted my Debian box.

Why is this happening?

# ls /etc/apache2/
-rw-r--r-- 1 root root 8.2K 2007-09-03 12:22 apache2.conf
drwxr-xr-x 2 root root 4.0K 2007-09-03 12:22 conf.d/
-rw-r--r-- 1 root root 895 2007-09-03 12:05 envvars
-rw-r--r-- 1 root root 0 2007-09-03 12:22 httpd.conf
drwxr-xr-x 2 root root 4.0K 2007-09-02 19:41 mods-available/
drwxr-xr-x 2 root root 4.0K 2007-09-03 12:22 mods-enabled/
-rw-r--r-- 1 root root 10 2007-09-03 12:22 ports.conf
drwxr-xr-x 2 root root 4.0K 2007-09-03 11:59 sites-available/
drwxr-xr-x 2 root root 4.0K 2007-09-03 12:22 sites-enabled/

# a2dissite default
This site is already disabled, or does not exist!

# a2ensite test
This site is already enabled!

# ls /etc/apache2/sites-available
-rw-r--r-- 1 root root 1.2K 2007-09-03 12:17 default
-rw-r--r-- 1 root root 1.2K 2007-09-03 12:22 test

# cat /etc/apache2/sites-available/test

ServerAdmin webmaster@localhost

DocumentRoot /home/test/www/

Options FollowSymLinks
AllowOverride None


Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
RedirectMatch ^/$ /apache2-default/


ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all


ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined
ServerSignature On

Alias /doc/ "/usr/share/doc/"

Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128




(no changes made to apache2.conf)

Re: newbie: why is Apache still going to default site?

am 03.09.2007 22:36:34 von deko

figured it out

RedirectMatch ^/$ /apache2-default/

Re: newbie: why is Apache still going to default site?

am 04.09.2007 00:28:12 von shimmyshack

On Sep 3, 9:36 pm, "deko" wrote:
> figured it out
>
> RedirectMatch ^/$ /apache2-default/

take another quick look at the documentation for vhosts
you only need this:



DocumentRoot /home/test/www/apache2-default
ServerName example.com
ServerAlias www.example.com
ServerAdmin webmaster@example.com
ErrorLog /var/log/apache2/error.log


The rest is pretty redundant and most of your directives are better
placed elsewhere than in the vhost seciton, so

Options Indexes FollowSymLinks MultiViews
AllowOverride None

should probably be server wide not just that for that vhost in all
likelihood.

There is more to it, you should have as your first vhost some default
that you will serve if no other vhosts match.

So google for "apache 2 vhost config" and follow some examples, the
simpler your config the better :)