However, since you are a new player, you probably don't have the credits to buy one (and it's quite possible that there is no ship for sale on your planet).
Your best bet is to join a faction (i.e. to get a job). They will generally provide you with a ship and will most likely pick you up. Additionally, you will earn more credits to eventually buy your own ship.
Alternatively, there should be an NPC-controlled Starport in the city that will allow you to travel to other NPC-controlled Starports on other planets (generally race homeworlds).
Last but not least, you can always earn CPs (the easiest way to do that is click topsite banners) and spawn a CP Bonus Ship in the starport. Just make sure you pick one with a hyperdrive, otherwise you'll be stranded in the system.