I am trying to setup virtual hosts on apache2 on Raspbian.

made a directory for www.example.com

wim@raspberrypi-lamp-server /var/www $ sudo mkdir www.example.com
wim@raspberrypi-lamp-server /var/www $ sudo mkdir www.example.com/htdocs
wim@raspberrypi-lamp-server /var/www $ sudo mkdir www.example.com/cgi
wim@raspberrypi-lamp-server /var/www $ sudo mkdir www.example.com/logs

create the virtual.conf file /etc/apache2/conf.d/virtual.conf

wim@raspberrypi-lamp-server /etc/apache2/conf.d $ sudo nano virtual.conf

#  We're running multiple virtual hosts.
NameVirtualHost *

virtual host config file

#  Example.com (/etc/apache2/sites-available/www.example.com)
<VirtualHost *>
    ServerAdmin webmaster@example.com
    ServerName  www.example.com
    ServerAlias example.com

    # Indexes + Directory Root.
    DirectoryIndex index.html
    DocumentRoot /var/www/www.example.com/htdocs/

    # CGI Directory
    ScriptAlias /cgi-bin/ /var/www/www.example.com/cgi-bin/
    <Location /cgi-bin>
            Options +ExecCGI

    # Logfiles
    ErrorLog  /var/www/www.example.com/logs/error.log
    CustomLog /var/www/www.example.com/logs/access.log combined

enable the site

wim@raspberrypi-lamp-server /etc/apache2/conf.d $ sudo a2ensite www.example.com

reloading apache gives me

wim@raspberrypi-lamp-server /etc/apache2/sites-available $ sudo /etc/init.d/apache2 reload
[....] Reloading web server config: apache2apache2: Could not reliably determine the server's fully qualified domain name, using for   ServerName
[Wed Aug 13 12:44:40 2014] [error] VirtualHost *:80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results
[Wed Aug 13 12:44:40 2014] [warn] NameVirtualHost *:80 has no VirtualHosts
. ok 

Now I can not see the index.html file in a webbrowser when I try to connect to the server. How can I resolve the [error] VirtualHost *:80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results and the warning: [warn] NameVirtualHost *:80 has no VirtualHosts

does the apache process need more than write access to the config files ? looking at the permissions all the config files are owned by root.

  • Have you tried commenting out the NameVirtualHost directive and restarting Apache? I've set up a few virtual hosts, and I didn't use NameVirtualHost at all. And as stated in @stefan's answer, use *:80 instead of *. – Steve Aug 13 '14 at 15:36
  • problem solved. There was some mistake in the tutorial I was following. NameVirtualHost *:80 <VirtualHost *:80> works the tutorial had NameVirtualHost *:80 <VirtualHost *>. thank you. Next step getting https running. – anatak Aug 14 '14 at 8:40

Looks like there is more than one entry of NameVirtualHost

Try to find out that u r using the right configuration file and that no NameVirtualhost is used before.

Your Warning "NameVirtualHost *:80 has no VirtualHosts" looks like that is one "NameVirtualHost *:80" Entry before yours and so apache does the following:

1.) Ignoring the other NameVirtualHost Entries

2.) Cant find a matching Virtualhost, cause they need to be exactly the same, either with Portnumber or without

So use something like

NameVirtualHost *:80
<VirtualHost *:80>

| improve this answer | |
  • I found NameVirtualHost *:80 in /etc/apache2/ports.conf I deleted the /etc/apache2/conf.d/virtual.conf file after enabling the sites I don't get the error anymore but still get the warning Warning "NameVirtualHost *:80 has no VirtualHosts" – anatak Aug 13 '14 at 9:39
  • NameVirtualHost *:80 <VirtualHost *:80> now the server reloads without any errors. – anatak Aug 13 '14 at 14:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.