I did this traveling solo and it was no problem and much cheaper than a taxi.
When you disembark the ship at Civitavecchia, their is a free shuttle bus which takes you and your luggage from the ship to the entrance to the port. Take this -it's too far to walk.
From the entrance of the port , you can walk to the Civitavecchia train station. This is easy to do -a flat terrain 15-20 minutes walk, but could be a little taxing if you have lots of luggage, so go slowly. I had a 25" suitcase on wheels and a rather thick backpack, and I didn't have any problems. There were others with much more luggage.
I was on Princess and the tour desk provided this detailed information, but I had already gotten the info online before I left. Your ship might be able to help as well.
Train schedules are at www.trenitalia.com/en
-for planning purposes, but I wouldn't purchase the ticket online since your disembarkation time can be earlier/later than originally planned.
No need to purchase tickets in advance; you can get them at the train station. Try to choose a train leaving from the first track, so you don't have to haul your luggage up and down stairs under the tracks. The tracks are right out the back from the ticket office -take a moment and check the track #. It's a small one room station -easily seen.
My best advice: plan to leave AFTER rush hour if you are traveling on a weekday morning. It can get very crowded. Be sure to either lock your luggage to a post by the door, or take a seat very near to the luggage so you can keep your eyes on it. Keep any small or hand luggage or valuables with you at all times, as there will be others that board the train and may have to stand around your luggage if all the seats are taken. I didn't lock my luggage, but it was so heavy I didn't expect anyone would want to run off and haul it with them.