I've worn out a half dozen hammocks on my boat. Mainly because I particularly favor the Mexican variety made of cotton so they eventually rot.
I rig my hammock on the boom. I have a nylon strap with 2 D rings that I slip between the mainsail and boom. I then clip a carabiner to the D rings and that holds one end of the hammock. The other end is held by a carabiner clipped to the bail on the end of the boom.
I have to open the companionway slide all the way so I can hang in the opening of the companionway. Works out great because I can then use the cabin top as sort of a table for drinks, books, laptops, etc. It's almost like sitting in an easy chair.