A computer program that creates webpages by communicating with the webserver in a specific way, the Common Gateway Interface (CGI).

Actually, they are not always scripts; compiled programs were used even in the very early days of CGI programming.