depends on the wall surface, hard plaster gives more rebound than sound insulating board for example.
as close as you can barely handle the rebound quick enough and don't forget keep a safe distance so u don't clash your racket on the wall
Do what you want, there's no right or wrong way. Make sure you know what kind of training effect you want, then select a distance you think is appropriate. Evaluate whether that distance is effective, and readjust if needed.