Apache Web server: Too many levels of symbolic links

After having this error presented to myself recently I thought it would be handy to let others know what it means!

So you’ve tried to restart/reload/start Apache on your Linux box and the following error has come up:

Too many levels of symbolic links

This is caused by one or more of the symlinks in the sites-enabled dir linking to its-self (maybe not directly but eventually ends up there :-(). I had my created my symlink using the command:

 ln -s <target> <destination>

But when I created the symlink my working directory was the same location as the file I wanted to link to, so I just typed:

ln -s somefile /var/somedir/somefile_link

Turns out this does not quite do as I had expected. (although not sure why)

The Solution

Basically the answer is to delete the symbolic link and start again this time using full path name, then is should all work:

ln -s /etc/apache2/sites-available/somefile /var/somedir/somefile_link