Troubleshooting (Apache)
Jump to navigation
Jump to search
NameVirtualHost *:80 has no VirtualHosts
On restarting Apache you get presented with the following warning
[Thu Jan 12 10:58:20 2012] [warn] NameVirtualHost *:80 has no VirtualHosts
This is generally caused by duplicate NameVirtualHost
entries in your config.
Perform the following in /etc/apache2
folder to identify where the entries and delete the unwanted duplicates..
grep NameVir * -R
Address Already In Use
On restarting Apache you get presented with the following error
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80 no listening sockets available, shutting down Unable to open logs [fail]
Apache is attempting to start but cannot bind (start listening on) TCP port 80 (or 443 if you're using SSL and the error refers to 0.0.0.0:443
, or another port if you're using non-standard ports.
The reason for the problem can vary, and you need ascertain what's already using the port by running netstat and grep'ing for port 80 (or whatever port Apache won't start on).
root@web2:/etc/apache2# netstat -lnp | grep :80 tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 20482/apache2
- If Apache is already listening on the port (as shown in above example, running with PID 20482)
- There is either a problem with the Apache config, and its trying to listen on the port twice, or you've got an old rogue process knocking around.
- Kill the process using the process ID
- EG
kill 20482
- EG
- Restart Apache, if it starts OK - problem solved!, otherwise continue
service apache2 restart
- Check your config for multiple servers on the port
- EG
grep -r 80 /etc/apache2/conf.d/* /etc/apache2/*.conf /etc/apache2/sites-enabled/*
- Multiple
<VirtualHost *:80>
are OK, multipleListen 80
orNameVirtualHost *:80
are not, fix as required
- EG
- If its another process you need to track down the cause and resolve.
- If you haven't accidentally caused the problem, your server may have been breached.
- Kill the process by name (dodgy.pl in example below, in-case there's more than one running)
- EG
killall -9 dodgy.pl
- EG
- From root, find the file and delete
- EG
cd /
- EG
find -iname dodgy.pl
- EG
rm -f /path/to/dodgy.pl
- EG