Measure the height and width of the new vanity cabinet you plan to install. Transfer the measurements to the wall, leaving at least a half inch of distance between the sides of the vanity and the bathroom wall.
Locate the studs in the wall, where you marked the outline of the vanity cabinet, using a stud finder. Measure the location of the stub-out pipe in the wall, relative to the back of the vanity cabinet.
Measure and mark where the stub-out pipe will meet the back of the cabinet. Make a hole larger than the stub-out pipe, using a drill with a hole-saw attachment. Slide the cabinet against the wall, lining it up with the outline you drew on the wall and inserting the stub-out through the hole in the cabinet. Push the cabinet until it sits against the baseboard on the bottom of the wall.
Drive wood screws through the thick wood strip in the middle of the cabinet’s back, placing the screws where you marked the location of the wall studs. Use screws that are at least half an inch longer than the wood strip inside the cabinet, so they anchor securely in the wall studs.