Before you install a carpet, you'll need to install carpet tacks. Carpet tacks are strips of wood designed to hold a carpet in place, so that you don't have to nail the carpet directly to the floor.
The first step, before installing carpet tacks, is to make sure the floor is clean. For wall-to-wall carpeting, carpet tack strips should be installed around the edges of the room, leaving a space about the width of your fingers between the baseboard and the edge of the strip. Position the strips with the tack side facing up. The arrows on the carpet tack should point toward the wall. Check that the tacks are angled toward the wall, as well. Cut the strips of carpet tack to fit the room, starting from the corner and working around obstacles like radiators or other permanent fixtures. The underside of the strips has nails. Hammer the nails into the floor; make sure that there are at least two nails for every strip.
The carpet is usually placed over a carpet pad. Once the carpet is rolled out and installed, it has to be tacked down. The carpet tack should grip the edges of the carpet through the carpet backing. Press down on the carpet firmly without using a hammer so the tacks don't break or bend before they get hold of the carpet. The tacks will grip the backing and hold the carpet in place. Once the tacks hold the carpet, bend the tips so that the tacks won't stick into your feet as you walk.