27.1. Requirements for CGI

There are some basic requirements for any program or script used for CGI:

  • The OS must be able to execute the program or script.

  • The program or script must be accessible by the Web server. This means it must exist in a directory the server can access and must be a file type that the Web server recognizes as deliverable.

  • The program or script must have sufficient rights or privileges to perform the tasks required of it (permission to access files it depends on, and so on).

  • The program or script must adhere to HTTP standards for any output it produces, including passing any appropriate headers as required (for example, a Content-type header before the content, and so on). To that end, the program or script should be in a language that provides robust output options, allowing for the output of special characters (line breaks, and so on).

  • The program or script must adhere to the guidelines governing the type of content it delivers. For example, if delivering HTML content, the program or script should endeavor to provide standards-compliant markup.

  • The program or script should also adhere to any standards dictated by the Web server delivering the script to end users.

There is a method of CGI known as Non-parsed Headers (NPH) scripting that allows a program or script to bypass the Web server entirely, taking on the entire burden of the headers itself. To accomplish NPH, you will need a Web server with NPH enabled, and you should name your NPH scripts starting with ...

Get Web Standards Programmer's Reference: HTML, CSS, JavaScript®, Perl, Python®, and PHP now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.