portrait – How to stack the focus so that the background and the subject are sharp?

I'd like to take a portrait with a 50mm lens, where the subject and the background are sharp. The usual method is to switch to a wide-angle lens or reduce the aperture, but I wonder if this is possible with the focus stack. The approximate workflow would look like this:

  1. Take a picture of the person from a tripod
  2. Ask the person to quickly get out of the frame
  3. Take a picture of the background
  4. Merge photos into post processing – how to do that?

I am looking for a way to perform step 4 automatically, rather than undergoing a tedious post – processing job in Photoshop. I guess that should be possible with modern software.