Focus shifting or bracketing
One method to acquire the photos for Focus stacking is focus shifting or bracketing. Just focus on the nearest thing you want to have in focus in the final picture, take a photo shift focus a tiny bit, take a new photo, shift focus take another photo and so on. Some newer cameras have the possibility shift focus/focus bracket in camera. Read more on this page, Focus shifting or bracketing