Pompeii is on the Circumvesuviana line between Sorrento and Naples. Get off at Pompei Scavi-Villa dei Misteri (not "Pompei"). The entrance is 50 meters from the platform.
Board at Sorrento, direction Naples. Get off at Pompei Scavi-Villa dei Misteri. Porta Marina entrance is next to the station.
Circumvesuviana, 30 min, โฌ2.80. Go early โ gates open 9am, tour buses arrive by 10:30.