The sun is far enough away (about 23,500 earth radii) that it took a long time before people knew accurately how far away the sun was. Certainly the ancient Greeks had calculated the distance, but they also knew that their results could be off. They basically had a lower limit for how far away the sun was.
Aristarchus was the first person to determine how far away the sun was. Based on observations of a lunar eclipse and on observations of a quarter-phase moon, he was able to calculate the relative sizes and distances of the earth, moon and sun. His methods were geometrically fine, but the data he used for the calculations were off, so his end results were off. Hipparchus and Ptolemy also tried to calculate the distance, but their results were no better than Hipparchus, and it is Ptolemies result of about 1200 earth radii that was used for centuries.
There really wasn't any real great improvement in measuring this distance until the time of Kepler. He realized that distance had to be at least three times greater than what Ptolemy had said. With the invention of the telescope, it finally becomes possible to measure small angles accurately. In 1635, Wendelin used the Greek methods based on telescopic measurements and found that the sun had to be at least 14,000 earth radii away.
With the telescope, new methods of determining the astronomical unit were devised. The first accurate measurement of the distance to the sun came in 1672 when Cassini and Richer made observations of Mars from different locations on the earth. They were then able to accurately measure the parallax of Mars - and then calculate the actual distance to Mars. Since they also knew how far away Mars was in AUs, they were then able to calculate calculate how big an AU actually was. They found that the sun was about 22,000 earth radii away.
After that, the transits of Venus across the face of the sun in 1761 and 1769 were used to determine the astronomical unit to be about 24,000 earth radii. A transit of Venus is when Venus comes exactly in between the sun and the earth. When viewed from different location on the earth, teams can record the eact times and paths of Venus across the face of the sun, which will all be slightly different due to parallax, which allows for the calculation of how far away the sun is.
In the 1960s, it became possible to directly measure the distance to Mars and Venus using radar, and so the astronomical unit was able to be calculated with even more precision. The current accepted value for the Astronomical Unit is 1.496 x 1011 meters, which is about 23,460 earth radii.