When you see the message AH00548: NameVirtualHost has no effect and will be removed in the next release
during Apache restart, it indicates you're using deprecated configuration syntax. This warning appears in Apache 2.4+ when the legacy NameVirtualHost
directive is still present in your config files.
Apache 2.2 required explicit NameVirtualHost
declarations, but since Apache 2.4:
# Old style (deprecated)
NameVirtualHost *:80
# New style (Apache 2.4+)
<VirtualHost *:80>
ServerName example.com
# ... other directives
</VirtualHost>
The error message points to /etc/apache2/ports.conf:8
where the obsolete directive resides. Modern Apache installations automatically handle name-based virtual hosts without explicit declaration.
1. Open your ports.conf file:
sudo nano /etc/apache2/ports.conf
2. Remove or comment out the NameVirtualHost
line:
# NameVirtualHost *:80 # This line should be removed or commented
3. Verify your virtual host configurations contain proper <VirtualHost>
blocks:
<VirtualHost *:80>
ServerName example.com
DocumentRoot /var/www/example
<Directory /var/www/example>
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
After making changes, always test your configuration before restarting:
sudo apache2ctl configtest
Then restart Apache:
sudo systemctl restart apache2
If you're hosting on multiple ports, ensure each port has its own <VirtualHost>
block:
Listen 80
Listen 443
<VirtualHost *:80>
# HTTP configuration
</VirtualHost>
<VirtualHost *:443>
# HTTPS configuration
SSLEngine on
SSLCertificateFile /path/to/cert.pem
</VirtualHost>
For systems upgraded from Apache 2.2, check these additional files for obsolete directives:
grep -r "NameVirtualHost" /etc/apache2/
The warning "NameVirtualHost has no effect and will be removed in the next release
" appears when running Apache 2.4 or later versions. This occurs because the NameVirtualHost
directive has been deprecated since Apache 2.3.11 and will be completely removed in future releases.
In older Apache versions (2.2 and earlier), you needed to explicitly declare which IP address and port combination would be used for name-based virtual hosts:
# Old configuration (Apache 2.2)
NameVirtualHost *:80
NameVirtualHost *:443
In Apache 2.4+, this is no longer necessary as the virtual host system automatically handles this functionality.
For Apache 2.4+, you should:
- Remove all
NameVirtualHost
directives from your configuration - Ensure your virtual hosts are properly defined
Here's a proper virtual host configuration example:
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
After making changes:
sudo apache2ctl configtest
sudo systemctl restart apache2
1. Having NameVirtualHost
in ports.conf
(line 8 as shown in your error)
2. Mixing old and new style configurations
3. Forgetting to remove all instances of the directive
If you're maintaining configurations that need to work across different Apache versions, you can use IfVersion
directives:
NameVirtualHost *:80
However, this approach is only recommended for transitional periods.
While the warning doesn't indicate any immediate functional issues, removing deprecated directives improves configuration clarity and prepares your setup for future Apache updates.