Awhile is an adverb meaning for a while. It usually follows a verb—for example:
Guests waited awhile for food . . . [Indie Wire]
When while is a noun, the phrase is two words—a while—for example:
But if they give him The Tonight Show back, maybe it ends up all right after a while. [Hollywood.com]
When considering whether to use awhile, mentally replace it with the phrase for a while. Would it make sense? If no, use a while. Try it with these examples:
The move has been anticipated for awhile . . . [iTWire]
Every once in awhile, even the best traveler needs to stop and ask for directions . . . [ABC News]
They thought for awhile that beta-carotene might help. [LA Times]
In each of these cases, it wouldn’t work to replace awhile with for a while, so the adverbial awhile should be changed to the two-word form.
The phrase awhile ago, technically meaning for a while ago, never makes logical sense.