L-brackets and hollow wall anchors. Home Depot/Lowes has about a hundred different kinds.
They make these new anchors, they look like big, plastic screws, with a sharp tip. You actually push/screw the thing into the wall, then screw the screw itself into that.
You screw one side of the L-brackets to the underside of the shelf, then you screw the L-bracket into the wall, via the anchor you put in the wall, above.
DO NOT screw directly into the sheetrock without using an anchor; it will rip out as soon as you put any weight on it!