PDA

View Full Version : CGI-BIN



sarr
11-23-2004, 09:31 PM
Does anyone know how to get a PHP file (attributes set 755), located in the /www/cgi-bin folder, to execute via the web?

I'd like to have my scripts outside of my htdocs folder (preferrably in the cgi-bin folder), named either script.php or script.cgi for example, and then be able to execute them by
http://www.site.com/cgi-bin/script.php (or .cgi -- whatever)

Can anyone help me with this?

Thanks!

wildjokerdesign
11-23-2004, 10:57 PM
Not sure that this is possible. I did run a test on one of my accounts and it generated this error in my error log:

(8)Exec format error: exec of /var/www/cgi-bin/cgibintest.php failed

I'll look at the problem more tommarrow and see if I can find anything else out.

jalal
11-24-2004, 02:16 AM
Hi Sarr

It should just work. Have you tried it?

If it is a PHP script it will *have* to have the .php extension. If it has a .cgi extension then it will be treated as a Perl script.

Edit:
Well, tried it myself, and it won't work of course as the whole point of the cgi-bin directory is to be outside of the website proper. Duh!

In fact, its probably not a good idea to have callable scripts in the cgi-bin directory (although you could put your include'd scripts there if you wanted).

Note that scripts such as 'neomail.pl' (for example) are run outside of the web server (via the '#!/bin/perl' line at the start of the script) and in theory you could create your php scripts with a '#!/bin/php' at the start of the script and run it that way, but I don't see any real advantage to going to all the trouble.