2

Every article I find about web servers suggest creating a sites-available and sites-enabled directory within apache/nginx/etc. Then, using symbolic (soft) links, create a link from the available to the enabled folder.

Why use symbolic links rather than hardlinks? With hardlinks, you can move the original file (rename it) as needed without needing to recreate the link. You can still delete the sites-enabled file without ruining anything, and the user/group permissions in any sane setup will be the same for both folders.

Can I safely use hardlinks instead of softlinks? Or is there a downside to hardlinks I'm not seeing? The major upside for me is not having to worry about recreating a symlink if I move/rename the original file.

  • I'd almost think that not having to recreate the link if you rename a file in sites-available would be a downside. If you're making a change there, you might want to make sure that the "live" stuff is still what you want. Aside from that, I don't see why hard links would be a problem (assuming, as is likely appropriate) that sites-available and sites-enabled are on the same filesystem – Eric Renouf Aug 26 '15 at 16:30
  • 3
    @EricRenouf That made me think of another good point: It makes it really hard to see which config files are actually linked. ls -al shows the softlink, but finding the connected hardlink configs requires a lot more effort. – Stephen Schrauger Aug 26 '15 at 16:33
4

I don't see any advantage to hard links.

With hardlinks, you can move the original file (rename it) as needed without needing to recreate the link.

That strikes me as a bug rather than a feature. If you want to disable a site (for example because you've just noticed that it has a major security hole), with symbolic links, you can just rename the sites-available entry. With hard links, and with potentially differing names, you have to hunt for the corresponding entry in sites-enabled.

If you want to rename a site, do it in both directories. Otherwise it gets confusing.

You can still delete the sites-enabled file without ruining anything,

True with either scheme.

and the user/group permissions in any sane setup will be the same for both folders.

With symbolic links, you don't have to worry about ownership or permissions in the sites-enabled directory.

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.