hkhosting.com

instructions to users

HOME
support/ change password | F.A.Q. | glossary
about us
technical specs
payment methods
contact us
hosting packages
server hosting
sign up
special offers
resellers
domain availability
jump to another section
Index

custom cgi scripts

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).

(a) Some commonly needed information

(b) Some common mistakes

1. FTP mode

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.

2. Permissions

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

(c) Other useful information

1. Filenames

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.

2. Compilers

The "c" compiler is gcc, the "c++" compiler is g++. A typical compile command is "gcc myprogram.c -o myprogram".

Copyright © 2023homeWhat Next Limited. All rights reserved. Quality Hong Kong web hosting. | Feedback | Terms & Conditions