36

What do you think would be solution to my problem?

user@admin:~$ sudo service apache2 restart
sudo: unable to resolve host admin
* Restarting web server apache2                                                
AH00548: NameVirtualHost has no effect and will be removed in the next release
/etc/apache2/ports.conf:8
0

2 Answers 2

50

From the Apache 2.4 documentation:

Prior to 2.3.11, NameVirtualHost was required to instruct the server that a particular IP address and port combination was usable as a name-based virtual host. In 2.3.11 and later, any time an IP address and port combination is used in multiple virtual hosts, name-based virtual hosting is automatically enabled for that address.

This directive currently has no effect.

The solution to your problem is to remove the NameVirtualHost directive.

3
  • 36
    I ran into the same error message after an upgrade, but simply removing the NameVirtualHost directive was not enough to get Apache working again for me. Every request got processed by the default vhost, regardless of IP and host header. Turns out something else had changed during the upgrade as well. The old apache2.conf permitted vhosts whose name did not end with .conf, the new configs silently ignored all such vhosts. Wanted to leave this comment here, such that the next person to run into that hopefully won't have to spend as much time on it, as I did.
    – kasperd
    Aug 9, 2014 at 10:53
  • 6
    be sure to change you conf(s) after removing NameVirtualHost so you have: <VirtualHost *:80>
    – OnePablo
    Oct 1, 2014 at 14:11
  • 1
    As a followup to kasperd's comment, .conf files in sites-available need the .conf extension. I came across this thread while upgrading from Apache 2.2 to 2.4. linode.com/docs/security/upgrading/…
    – wruckie
    Mar 10, 2016 at 12:50
0

So 10 years later, it still complains about this, but it's essential in order to have virtual hosts working with a shared IP. I'd have no problem assigning a free ipv6 address to each virtual host, but that's just not going to work until ipv6 is ubiquitous, and I really don't want to be buying up a bazillion IPv4 addresses.

bar@foo:~$ cat /etc/apache2/ports.conf
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf

Listen 80

<IfModule ssl_module>
        Listen 443
        NameVirtualHost *:443
        SSLStrictSNIVHostCheck off
</IfModule>

<IfModule mod_gnutls.c>
        Listen 443
</IfModule>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .