How to provide a 5 volt rail from 24 volt source
You can get switching converter modules that have a 7805 pinout with a form factor that's about the same as a 7805 heat sink (but if you bet me money, I get to choose the heat sink that it's the same as :).

I'd use one of those.  They're a few bucks in onsie quantities, but you have to put almost zero effort into designing them in.