This has been a problem since I was a kid. Now however we have things called LED strips. these things are great: low power consumption, cheap, long life, and best of all very low heat. This has always been a problem and a danger when putting a light bulb in a closet. That problem is eliminated with the LED strips.
Step 1: The Bom and Assembly.
This really took me about a half hour to do. The only part that might be objectionable is running electricity into a closet. Its probably against code, but then again code was written when incandescent bulbs were the norm. they never considered low voltage low amp low heat LED bulbs. If you install this, you do this at your own digression and your own responsibility to meet your own local fire and electrical code.
This is what I used/bought for the project (the BOM (bill of material:)
1) 16.4' led strip, I used only 1/3 of it. I can do 2 more closests with this one $4 strip!!! (5050 led strip warm white from ebay)
2) 12v 5a power supply (laptop brick style from ebay. (this was overkill a 2amp version would be fine and are cheaper) $6
3) old extension cord ($1)
4) SPDT (single pole double throw) momentary switch, aka the switch from the refrigerator door. The important thing is it has the NO terminal (normally open) because you want to have the light turn on when the door is OPEN aka the switch is NOT made (aka the backwards of a doorbell) The door when closed will close the switch, and you want this to cut the electricity to the LED strip, when the switch is open, you want the current to flow to turn on the LED strip. this is probably the most confusing part of this whole project.
5) some zip wire cut from old extension cords ($1) You are going to break into the used extension cord and tap into the SPDT switch to cut the power I'll draw a diagram later.
6) some paint sticks from the hardware store. to be used to mount the switch.
For the instructions, here is what I did:
1) the led strip has double back tape, I cut a length that was the length of thedoor and taped it to the inside of door jam so the door won't hit it. I left the connector on the section of led strip at the bottom of the door.
2) I plugged the led strip into the 12v power supply. I had to match the red and black wires and taped them with electrical tape.
3) I poked a hole through the closet wall into the neighboring bedroom, snaked the extension chord through the wall I cut the extension cord and reattached the wires so I only needed a really small hole in the wall. I would of had to cut the extension cord anyway to make room for the switch.
4) using enough wire to run the switch up to the top of the door. I mounted the switch such that when the door closed it would push on the button to make the switch. I cut up a paint stick and glued the pieces together to make a good stand, then I glued the switch to it with some 2 part epoxy and string. then some wood screw to screw it into the door frame.
Step 2: Wiring Diagram.
I don't remember but I probably soldered everything, Anyway here is a layman's wiring diagram. If you don't solder twist your wires tighthtly, and individually wrap them in electrical tape.