Lily Evans was born on January 30, 1960. James Potter was born March 27, 1960. They got married, and shortly thereafter had a son, Harry James Potter, who was born July 31, 1980. A year after, in 1981 on Halloween, both of Harry's parents died.
Nine years later, in 1990, Harry turned ten. He turned eleven and began attending Hogwarts in 1991-1992. His second year was 1992-1993, and so on. He should have begun his seventh year (but instead hurried into hiding) in 1997, which turned over into 1998. Harry's seventh year finished (or at least, it would have, had he attended Hogwarts that year) in 1998. This happens to be the same year that JK Rowling published the very first Harry Potter book, but the dates do not correspond. Harry is supposedly 17 in the beginning of 1998, although technically he's only one.
To make it clearer, I'll answer each of your questions separately (though you could pick them out of my above answer if you so chose):
Technically, the actors are older than they're supposed to be. Rupert Grint (Ron Weasley) is 24 when he's supposed to be playing as a 17-year-old.
The first book was published in 1997, and was released in 1998, but Harry's first year of Hogwarts and the year of publication are not the same; Harry started attending in 1991.
Hope that cleared everything up.