apache - Warning: DocumentRoot * does not exist on Centos 6

06
2014-04
  • user1213807

    My virtual hosts lines:

    <VirtualHost *:80>
        ServerAdmin [email protected]
        DocumentRoot /www/docs/example.com
        ServerName example.com
        ErrorLog logs/example.com-error_log
        CustomLog logs/example.com.com-access_log common
    </VirtualHost>
    

    And when I apache restart (sudo apachectl -k stop) get this error:

    Warning: DocumentRoot [/www/docs/example.com] does not exist
    

    I've checked some ways:

    All files and directories permissions is OK, everything 755. I think, maybe this error about SeLinux and disable it. But not working. Still same error.

    How can I fix this problem?

  • Answers
  • Manolo Salsas

    You have to escape the . symbol. Try this instead:

    DocumentRoot /www/docs/example\.com
    

  • Related Question

    apache - Virtual host errors, warnings, and issues on Ubuntu
  • Andrew

    I probably have something set up wrong. Seems I always have problems trying to configure my Virtual Hosts correctly.

    I'm getting this error after restarting Apache:

    Restarting web server apache2
    apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
    [Wed Oct 14 17:39:17 2009] [warn] VirtualHost site1.local:0 overlaps with VirtualHost site2.local:0, the first has precedence, perhaps you need a NameVirtualHost directive
    

    Why is it using 127.0.1.1 for ServerName? And why isn't my site2.local virtual host working?

    Here's my hosts file:

    # /etc/hosts
    127.0.0.1   localhost site1.local site2.local
    127.0.1.1   andrew-laptop
    
    
    # The following lines are desirable for IPv6 capable hosts
    ::1     ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    ff02::3 ip6-allhosts
    

    In /etc/apache2/sites-available I have 3 files: default, site1.local, and site2.local

    default:

    NameVirtualHost *
    <VirtualHost *>
        ServerAdmin webmaster@localhost
    
        DocumentRoot /var/www/
        <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 +SymLinksIfOwnerMatch
        	Order allow,deny
        	Allow from all
        </Directory>
    
        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/"
        <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>
    

    site1.local:

    <VirtualHost site1.local>
        ServerAdmin webmaster@localhost
        ServerName admin
        DocumentRoot /home/andrew/Projects/site1/public
        CustomLog /var/log/apache2/site1-access.log combined
        <Directory /home/andrew/Projects/site1/public>
            Options FollowSymLinks
        AllowOverride All
        </Directory>
    </VirtualHost>
    

    site2.local:

    <VirtualHost site2.local>
        ServerAdmin webmaster@localhost
        ServerName admin
        DocumentRoot /home/andrew/Projects/site2/public
        CustomLog /var/log/apache2/site2-access.log combined
        <Directory /home/andrew/Projects/site2/public>
            Options FollowSymLinks
        AllowOverride All
        </Directory>
    </VirtualHost>
    

    If any of this seems wrong, please let me know. Please help me figure out what is wrong with my setup.


  • Related Answers
  • phoebus

    I believe you should be using site1.local / site2.local as your ServerName parameters in your virtual host files...at least that's what works for me.

    The 127.0.0.1 ServerName default is likely being set in apache2.conf.

  • quack quixote

    Here's one problem: in /etc/hosts, your localhosts line is wrong. You have this:

    # /etc/hosts
    127.0.0.1   localhost site1.local site2.local
    

    You need to have this:

    # /etc/hosts
    127.0.0.1   localhost.localdomain localhost
    

    The top line is important. You can assign site1.local and site2.local to nearly anything else, but the top line needs to include both localhost.localdomain and localhost.

    I'm not sure what black magic is responsible, but things break weirdly in Ubuntu 9.04 and Debian 5.0.3 if that line gets changed to anything else. My recent Debian install had the same Apache errors (plus some other interesting breakages) until I rolled back my own changes to that line.

    Since you still need to define site1.local and site2.local, you could do it like this:

    127.0.1.1   andrew-laptop site1.local site2.local
    

    But Apache might prefer different IP addresses for the sites, so you'd probably be better off doing it this way:

    127.0.1.1   andrew-laptop
    127.0.1.2   site1.local
    127.0.1.3   site2.local
    

    The 127.0.0.0/8 network is loopback, so you can pick any 127.x.x.x address you like for them.