Ex-Northampton boss Gary Johnson had been linked with the post before his return to former club Yeovil.
McGhee returns to English football, where he has managed Reading, Millwall and Brighton among others, after a disappointing spell in charge of Aberdeen where he had enjoyed huge success as a player.
"I'm quite nervous but I hope the nerves show that I'm not complacent and thinking that it's going to be easy," he told BBC Points West.
"I know there's work to be done and I'm looking forward to it.
Rovers, currently six points above the Cobblers, come to Sixfields on Tuesday 6 March.