Measurement and planning:
Use a measuring tape to take the height and width of your closet. Decide the number of shelves you desire to install in it. Shelves could be of same length and height and can also be different based on your requirement. Make a paper template of your closet with all the measurements and indicate shelf positions, height and width. If you want to go with the standard practice, keep a distance of 12 inches between each shelf.
use a stud finder to locate the studs in the wall. Draw pencil marks over these studs. This is where you will screw your brackets
Use a pencil to mark marks inside your closet to indicate the position of your shelves. These marks will help in installation.
You can also get pre-fabricated wood shelves. However, it is better to take wooden boards to a hardware store and have them cut out shelves for you according to your desired measurements. You can also prime the shelves before installation.
You also have to get the shelf brackets which will hold the weight of the shelves. They are available at any hardware store. You can also make out wooden brackets for your shelves.
Drill pilot holes over the stud marks you made in the wall. These holes should be smaller than the diameter of the screws you have to install the brackets. Hold the screw opening of the hanger over these holes and drive the screw through it. Do it for every bracket you have to install. Normally you need two brackets to hold a shelf, one at each end. However, longer shelves can need reinforcement in the center.
Hold the shelf over the bracket and mark points where you will drill holes. Drill pilot holes on these points and use them to drill short wood screws into the shelf and bracket, attaching them both together.