The main train station in Tanger (known as Tanger, or Tanger Ville) is the end of the line. It’s closer to the city centre than the original end-of-the-line station, known as Tanger Morora, but is still quite a long walk, so if you’re heading to the Tanger ferry port, you should take a petit taxi.
Note that Port of Tanger, and Port of Tanger Med are different ports. Port of Tanger is a 10 minute taxi ride from the train station. Tanger Med, the new commercial port, is a 40km train or taxi journey to the east towards Ceuta.