You can either get the bus, Coast To Coast Coach or ferry to Sorrento. Then get the local train to Pompeii and the Campania Express is the better train but it's not frequent. The ruins are a short walk from the train station and you can join a guided tour for a small fee when you get there.
Info on the other train below which runs roughly every 30 minutes from Sorrento to Pompeii.
Or you can get a ferry or bus to Salerno and a train to Pompeii but the station for this train is further from the ruins. I have not used this train.
Bonniebelle4, another TA regular has a good idea on your other post. "If you have interest in seeing Pompeii (Herculaneum or Vesuvius) on the way, (from Rome) take the fast train to Naples and hire a private transfer. They will wait with luggage while you tour the site and then take you on to Positano."