I wish I could tell you there was a magical formula I used to get this railing on. I was just winging it with some visual measuring and crossed fingers. I have no idea if it is actually straight, but it looks it, so I suppose that is all that matters.
The stair assembly fits so snugly that I didn't bother with glue along the wall. I did glue the foyer newel post to the floor and the railing.