jump to another section | Index |
CGI scripts can be valuable tools to interact with visitors to your site. To get your scripts working, you will need to upload them in ASCII mode and set them to be executable (mode 700).
Many FTP clients don't know that *.pl and *.cgi files should be uploaded in ASCII mode, and use binary instead. This results in a CGI that has an extra character (control-M) at the end of each line, and won't work.
If your CGI script's instructions tell you to set the mode of a file or directory to 777, don't do it. Their instructions incorrectly assume that your web server runs CGI insecurely, and needs these permissions to be set. If you set a directory or CGI script to mode 777, the web server will refuse to run it due to the insecure permissions you gave it (and tell you "500 internal server error").
Correct permissions:
CGI scripts: 700 (secure) or 755 (publicly readable)
Data files: 600 (secure) or 644 (publicly readable)
Directories: 755
All other files: 644
You can name a file *.cgi and put it anywhere inside your "www" directory and it will work. The "cgi-bin" directory forces anything inside to be treated as a CGI, regardless of the filename. All HTML files and pictures must be outside the cgi-bin directory.
The "c" compiler is gcc, the "c++" compiler is g++. A typical compile command is "gcc myprogram.c -o myprogram".