It depends where you are in Egypt.
1) You can fly to Amman from Cairo and then from Amman take a
bus to Petra.
2) If you are on the Sinai peninsula, take the ferry from
Nuweiba to Aqaba and then catch a public bus to Petra. You can also
take a taxi.
Please see related links for timetables and fares.