Formal:
* Il y a deux ans. (literally "There are two years.") This is the most common and formal way to say it.
Informal:
* Deux ans en arrière. (literally "Two years backwards.") This is a more informal way to say it.
Other options:
* Il y a deux années. (This is more formal than "Il y a deux ans.")
* Depuis deux ans. (This is more appropriate for situations where you are talking about something that happened in the past and continues to this day.)
The best way to choose which phrase to use depends on the context and the level of formality you want to achieve.