With great difficulty over the better part of a century.
The Great Trigonometrical Survey of India started from the ocean in 1802, and 100 feet at a time, took measurements and did a bunch of math, and worked there way across the sub-continent to the Himalayas, completing in 1871.
It was a great scientific achievement, lead during some of its more important years by George Everest, who received a knighthood for his efforts.
The basic technique is fairly simple. You start with two sticks at sea level, a decent distance apart, and measure their exact longitude and latitude. Then you put a third stick some distance away and inland, making a triangle. Based on the distance between the first two sticks and the angles they form with the third stick, you can compute the third stick's exact position and elevation.
Once all that is done, you repeat, planting a stick further inland and drawing a new triangle.
The Great Survey did this with better instruments, better technique, and on a greater scale than had ever been done before.
Also, math and triangulation. Trigonometry has been around a long long time.
See, with just one side of a triangle and the angle between it and another side, you can figure out the missing side. So if you make the triangle such that once side is easy to measure, and then you use a protractor and your vision to determine the angle, you can math the height.
A field of study called geodetics used instruments called Theodolites. Sometimes they were called diopters. The theodolites almost look like telescopes but with a lot of rulers on it so you can determine which direction the telescopes are pointing, up-and-down and side-to-side.
Using the measurements from the rulers on the theodolite, you can use math called Trigonometry to tell you how far away something else is.
In the case of Chomolungma (Mt Everest), the British started from the ocean in India and measured all the way across the country until they could see the mountain. After getting their measurements, they did the math and found out how tall they thought the mountain was.
One way is by making a cup of tea.
Water boils at 100°C only at sea level. The temperature at which water boils varies based on air pressure. For every 1000 metres, the boiling point drops by about 5 degrees. Thus, with a kettle and a thermometer you can estimate altitude.
Trigonometry. In high school we visited an amusement park. By being a known distance from the base of the top of the roller coaster hill (length and angle (90 degrees) of one side of the triangle) and then calculating the angle to the top of the structure using a sighting scope, we could calculate the height. [This pic](https://image.slidesharecdn.com/heightanddistances-120108094402-phpapp01/95/height-and-distances-12-728.jpg?cb=1326016394) sums it up.
They often didn't.
I can't find the citation easily, but in the late 1990s/early 2000s, a very large number of Australian mountains and waterfalls had their heights revised after someone realised that there were a stupidly large number of them that were listed as having a height of 305 metres. Some went up, most went down - a couple by more than half.
It turned out that the official height figures were often the estimates of the original explorer/surveyor and no-one had been arsed to actually measure them, especially because they weren't a suspiciously round number.
Of course, the reason that they weren't a round number was because during metricisation in the 1970s a height of 1,000 feet had been converted to 305 metres, but that was before heights were recorded on computers and easily checked against each other.