Gesso Comes First
Gesso is painted onto the canvas to seal and prime it before the oil paint is applied. The linseed oil in oil paint will deteriorate an unprimed canvas. Gesso is the preferred sealer for the porous canvas. It is an isolating layer between the canvas and the paint. It also provides a good surface texture for receiving the paint. Once made from rabbit skin glue and chalk the improved version today is made from polymer emulsion and titanium dioxide. All surfaces intended for oil paint will benefit from a base coat of gesso. If you are stretching un-primed (raw) canvas you will want to use Rabbit skin glue as an additional sealer. (See Canvas/Stretching your own canvas)
Pre-primed canvas that has been stretched will have small cracks that a new coat of gesso will seal. A crack in the primer can create a discoloration through many layers of paint and leaves the canvas exposed to deterioration.
Gesso is bright white and needs be toned down to a light neutral color for most paintings. Acrylic paints are effective toners for the gesso. I recommend Liquitex Acrylic Gessos (affiliate link) for priming a canvas.
Gesso may be applied in layers and lightly sanded between coats. Make the brush strokes horizontal for the first coat and vertical for the next. The gesso may be thinned with water to reduce the texture of the brush strokes. It takes about an hour to dry.