Only one of the buildings used for Hogwarts was a real life school. The rest were "castles and cathedrals and churches [in Great Britain] that are all more than 500 years old," says David Heyman, a producer. "Because Hogwarts was built more than a thousand years ago, we wanted to use structures from that period." Here are two locations:

Alnwick Castle:

Alnwick
The Duke of Northumberland let the film crew use his home for the scenes of the kids' flying lessons and shots of them walking to Hagrid's hut. The oldest parts of the castle date back to the year 1096.

Durham Cathedral:

Durham
Although most of the Hogwarts interiors were filmed at a movie studio, some scenes in classrooms and corridors were shot here. This massive stone structure was built 900 years ago.
Source: Nickelodeon Magazine, October 2001 Issue