ubuntuusers.de

apache2: File does not exist: /htdocs

Status: Gelöst | Ubuntu-Version: Nicht spezifiziert
Antworten |

floogy

Anmeldungsdatum:
21. Juli 2006

Beiträge: 3297

Wohnort: Koblenz

Hallo,
Ich habe ein Problem bei der Umstellung auf apache2.
Folgende Dokumentation wird verwendet:
apache
http://forum.ubuntuusers.de/topic/92688/next/
http://httpd.apache.org/docs/2.2/de/vhosts/name-based.html

Ich habe bereits ServerName localhost in /etc/apache2/apache2.conf eingetragen.

So bekomme ich nicht mehr folgende Meldung beim restart:

apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

Trotzdem besteht weiterhin das Problem, dass der Hauptserver nicht funktioniert:
http://localhost im Adressfeld des Browsers wird zu http://localhost/ und gibt diese Fehlerseite (404) aus:

Not Found
The requested URL / was not found on this server.

Im error.log steht dann:

[error] [client 127.0.0.1] File does not exist: /htdocs

Das scheint hardgecodetes fallback zu sein, da es sich in der Konfiguration nicht findet:

$ rgrep -C3 htdocs /etc/apache2
/etc/apache2/magic-# Magic data for mod_mime_magic Apache module (originally for file(1) command)
/etc/apache2/magic:# The module is described in htdocs/manual/mod/mod_mime_magic.html
/etc/apache2/magic-#
/etc/apache2/magic-# The format is 4-5 columns:
/etc/apache2/magic-#    Column #1: byte number to begin checking from, ">" indicates continuation
--
/etc/apache2/README-magic
/etc/apache2/README-
/etc/apache2/README-    Magic data for mod_mime_magic Apache module, documented in
/etc/apache2/README:    htdocs/manual/mod/mod_mime_magic.html.  You probably don't
/etc/apache2/README-    need to touch this.
/etc/apache2/README-
/etc/apache2/README-mods-available/

Das selbe Bild ergibt sich bei a2ensite default sowie bei a2dissite default.

$ sudo egrep -v '#|^ *$'  /etc/apache2/sites-available/default
NameVirtualHost 172.16.240.1:80
<VirtualHost 172.16.240.1:80>
        ServerAdmin webmaster@localhost
        ServerName localhost
        DocumentRoot /var/www/

        ServerAlias localhost

        DirectoryIndex index.php index.html index.htm

        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>
        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ 
                <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews -Indexes +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>
        ErrorLog /var/log/apache2/error.log
        LogLevel warn
        CustomLog /var/log/apache2/access.log combined
        ServerSignature On
    Alias /doc/ "/usr/share/doc/"
    <Directory "/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
    </Directory>
</VirtualHost>

Weshalb sucht er also in /htdocs ? Oder sucht er /var/www/htdocs ?
Er soll aber /var/www anzeigen, und damit das dort vorhandene /var/www/index.html.

Die anderen vhosts funktionieren.

Was ist hier falsch?

Vielen Dank im Voraus.

Weitere Konfigurationsdateien:

$ sudo egrep -v '#|^ *$'  /etc/apache2/apache2.conf 
ServerRoot "/etc/apache2"
ServerName localhost
LockFile /var/lock/apache2/accept.lock
PidFile /var/run/apache2.pid
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15
<IfModule mpm_prefork_module>
    StartServers          5
    MinSpareServers       5
    MaxSpareServers      10
    MaxClients          150
    MaxRequestsPerChild   0
</IfModule>
<IfModule mpm_worker_module>
    StartServers          2
    MaxClients          150
    MinSpareThreads      25
    MaxSpareThreads      75 
    ThreadsPerChild      25
    MaxRequestsPerChild   0
</IfModule>
User www-data
Group www-data
AccessFileName .htaccess
<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
</Files>
DefaultType text/plain
HostnameLookups Off
ErrorLog /var/log/apache2/error.log
LogLevel warn
Include /etc/apache2/mods-enabled/*.load
Include /etc/apache2/mods-enabled/*.conf
Include /etc/apache2/httpd.conf
Include /etc/apache2/ports.conf
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
ServerTokens Full
ServerSignature On
Include /etc/apache2/conf.d/
Include /etc/apache2/sites-enabled/
$ ls  /etc/apache2/conf.d/
apache2-doc  charset  php4.conf        phpmyadmin.conf.dpkg-tmp  tetex-doc
backuppc     modxslt  phpmyadmin.conf  scoreboard
$ sudo egrep -v '#|^ *$'  /etc/apache2/httpd.conf
$

/etc/apache2/httpd.conf ist also leer, envvars ebenfalls. ports.conf entspricht dem ubuntu-paket (LISTEN 80 und 443).

Svanner

Anmeldungsdatum:
5. Januar 2007

Beiträge: 209

floogy hat geschrieben:

$ sudo egrep -v '#|^ *$'  /etc/apache2/sites-available/default
NameVirtualHost 172.16.240.1:80
<VirtualHost 172.16.240.1:80>

Hey,
bist du dir mit der IP-Addresse ganz sicher? Wenn ich dich richtig verstanden habe, greifst du ja auf localhost (127.0.0.1) zu, somit ist dies nicht die vHost-Config für den localhost.

mfg Svanner

floogy

(Themenstarter)

Anmeldungsdatum:
21. Juli 2006

Beiträge: 3297

Wohnort: Koblenz

Ja, es hat leider etwas damit zu tun, wie ich inzwischen feststellen musste, obwohl es so im apache 1.3.x funktionierte ☹ :

Ich beschreibe nun mal 4 Fälle:
1.)
/etc/apache2/apache2.conf

ServerName localhost


/etc/apache2/sites-available/default

Name
 172.16.240.1:80
<VirtualHost 172.16.240.1:80>
$ egrep  VirtualHost  /etc/apache2/sites-available/*|egrep -v '#|^ *$|</VirtualHost>' 
/etc/apache2/sites-available/default:NameVirtualHost 172.16.240.1
/etc/apache2/sites-available/default:<VirtualHost 172.16.240.1>
/etc/apache2/sites-available/vh1:<VirtualHost 172.16.240.1>
/etc/apache2/sites-available/vh2:<VirtualHost 172.16.240.1>
/etc/apache2/sites-available/vh3:<VirtualHost 172.16.240.1>
/etc/apache2/sites-available/vh4:<VirtualHost 172.16.240.1>

Bei dieser Konstellation funktioniert localhost nicht (wie bereits beschrieben), allerdings mit IP-Eingabe sehr wohl (http://172.16.240.1).
Alle vhosts vh1-vh4 gehen.

1b)
Wird folgendes in die /etc/apache2/apache2.conf eingetragen: ServerName 172.16.240.1, verhält es sich genau gleich.

2.)
/etc/apache2/apache2.conf

ServerName localhost


/etc/apache2/sites-available/default

NameVirtualHost 127.0.0.1:80
<VirtualHost 127.0.0.1:80>
$ egrep  VirtualHost  /etc/apache2/sites-available/*|egrep -v '#|^ *$|</VirtualHost>' 
/etc/apache2/sites-available/default:NameVirtualHost 127.0.0.1
/etc/apache2/sites-available/default:<VirtualHost  127.0.0.1>
/etc/apache2/sites-available/vh1:<VirtualHost  127.0.0.1>
/etc/apache2/sites-available/vh2:<VirtualHost  127.0.0.1>
/etc/apache2/sites-available/vh3:<VirtualHost  127.0.0.1>
/etc/apache2/sites-available/vh4:<VirtualHost  127.0.0.1>

Hier ist es gerade umgekehrt: Alles was nach 127.0.0.1 aufgelöst wird funktioniert, aber die nach 172.16.240.1 aufgelösten vhosts bringen den beschriebenen [client 172.16.240.1] Fehler File does not exist: /htdocs .

2b)
Wird nun nur /etc/apache2/apache2.conf nach

ServerName 172.16.240.1

geändert, so bleibt das Ergebnis gleich.

Ich denke, es könnte am dns liegen (pdns)

$ dig +short localhost
127.0.0.1
$ dig +short localhost.mypages.home
127.0.0.1
$ dig +short www.mypages.home
172.16.240.1

Womöglich würde es gehen, wenn er folgendes ausgeben würde:

dig +short localhost
127.0.0.1
172.16.240.1

Allerdings klappte das vorher mit dem apache 1.3.x problemlos.

Folgendes habe ich noch beobachten können: Ich bekomme diesen Fehler, wenn in der default Hauptserver kein NameVirtualHost eingetragen ist:

 [warn] VirtualHost 172.16.240.1:80 overlaps with VirtualHost 172.16.240.1:80, the first has precedence, perhaps you need a NameVirtualHost directive


Und

 [warn] NameVirtualHost 172.16.240.1:80 has no VirtualHosts

wenn NameVirtualHost in allen vhost auftaucht.

floogy

(Themenstarter)

Anmeldungsdatum:
21. Juli 2006

Beiträge: 3297

Wohnort: Koblenz

Ich habe den Fehler gefunden. Ich habe den pdns-recursor gestoppt, so dass alle Anfragen über resolv.conf und /etc/hosts aufgelöst werden.

sudo /etc/init.d/pdns-recursor stop


Danach habe ich die erste Zeile in /etc/hosts auskommentiert:

$ head /etc/hosts
#127.0.0.1 ubuntu.mypages.home localhost.mypages.home localhost.localdomain localhost ubuntu
172.16.240.1 ubuntu.mypages.home localhost.mypages.home localhost.localdomain localhost ubuntu


Und den pdns-recursor wieder gestartet:

sudo /etc/init.d/pdns-recursor start
[...]
Oct 26 16:27:16 Inserting forward zone 'localhost.' based on hosts file


Nun ergibt dig zwar immer noch

$ dig +short localhost
127.0.0.1

aber der apache ist nun mit der Konfiguration in 1b) zufrieden.
Svanner, danke für den Hinweis.

Antworten |