Yes, you can do it on your own and it's probably a better use of your time vs. a tour that may go places you're not as interested in.
You've got a nice, long port day, which is good news. If you're up and out as soon as they let you off the ship you should be able to make either the 7:44 or the 7:58 regional train to Rome. They will be crowded and somewhat uncomfortable, so you're forewarned.
At the other end of the day there are returns at 17:27 or 17:58 that would have you back in Civitavecchia an hour or slightly more before your departure time.
That makes for a nice long day, plenty of time to see both sites.
I have a bus to catch so I can't give you all the links right now, but I'll bet that before I get back another member will have provided them.
For train info here: EN - Trenitalia