A webserver need not release any information to the outside world about what technology it uses, so there's no sure way. But there are clues as others have already mentioned. Another clue is if you get one of the standard error pages generated by the server-side scripting engine or by the server software itself.
But these are mere clues. A webserver can be configured to handle filename extensions practically as it likes; you could probably even configure one (or write your own) to process .php as Perl, use .asp to serve static PNG images and so on, make it go by the first letter of the filename, have it get both the file and the technology used to handle it out of a database, and so on. And even forge error pages in the style of some software your site doesn't run on, or add time delays to make you think it uses some slower technology or runs on a slower machine than it actually does....