The term "compiled language" doesn't make any sense. A language isn't compiled. A language isn't interpreted. A language just is.
Whether a particular implementation uses a compiler or an interpreter is a trait of the implementation and has nothing to do with the language. Indeed, every language can be implemented with either an interpreter or a compiler. In fact, the vast majority of modern language implementations (CPython, Perl, PHP, YARV, IronRuby, HotSpot, Mono, CLR, TraceMonkey and so on) use both an interpreter and a compiler. HotSpot for example constantly switches between compiler and interpreter depending on which is faster.
So, to answer your question: every language that can access environment variables, read text from stdin and write text to stdout can be used with CGI and thus Apache (and indeed pretty much every webserver on the planet). And every language can be compiled. Therefore, every language can be used in the way you describe.