Bonus points if your camera has in-camera focus stacking. If it does, this makes the process infinitely easier! If not, follow these instructions.
You’d be surprised how well Photoshop or Helicon Focus can auto-align images that aren’t shot on a tripod. This is a technique I use a lot when I want to capture scenes quickly and not spend all the time setting up my tripod perfectly. If you have time and know you want to shoot one particular composition, it’s always better to use a tripod, but if it isn’t available, know how to pick the right settings to do it handheld too!