Where is /cgi-bin/ and who puts files in it?

One of my clients is trying to make a form work with /cgi-bin/mailto but I can't figure out:

1) Where is the global /cgi-bin/ supposed to be?

2) Who is responsible for putting files in it?

Thanks!

XServe G5, Mac OS X (10.4.6)

Posted on Mar 1, 2007 7:52 AM

Reply
Question marked as Top-ranking reply

Posted on Mar 1, 2007 8:15 AM

If you wan't to make the CGIs work server-wide, the default location is /Library/WebServer/CGI-Executables. The default web server setting already has a ScriptAlias directive pointing any address written as www.example.com/cgi-bin redirect to this directory. The global webmaster... the server administrator is responsible for all CGIs in this directory.

If you want to let each individual webmasters take care of their own CGIs, each website can override this by creating their own cgi directory within their own web directory. This directory can be named anything (e.g. "/scripts/"). Generic form-to-mail type CGIs are usually placed in the /Library/Web... directory for global usage, but if a script is only used by a single website, it's usually put inside their own web directory. You may want to tweak their httpd.conf file to assign this folder as the ScriptAlias target. When you do this, websites can execute the CGIs with the .cgi extension (i.e. pass the script on to whatever compiler/interpretor, like perl). Otherwise, you'll need to name each script like scriptname.pl or scriptname.c instead of scriptname.cgi.

Extended Keyboard Server Mac OS X (10.4.8)
7 replies
Question marked as Top-ranking reply

Mar 1, 2007 8:15 AM in response to wpns

If you wan't to make the CGIs work server-wide, the default location is /Library/WebServer/CGI-Executables. The default web server setting already has a ScriptAlias directive pointing any address written as www.example.com/cgi-bin redirect to this directory. The global webmaster... the server administrator is responsible for all CGIs in this directory.

If you want to let each individual webmasters take care of their own CGIs, each website can override this by creating their own cgi directory within their own web directory. This directory can be named anything (e.g. "/scripts/"). Generic form-to-mail type CGIs are usually placed in the /Library/Web... directory for global usage, but if a script is only used by a single website, it's usually put inside their own web directory. You may want to tweak their httpd.conf file to assign this folder as the ScriptAlias target. When you do this, websites can execute the CGIs with the .cgi extension (i.e. pass the script on to whatever compiler/interpretor, like perl). Otherwise, you'll need to name each script like scriptname.pl or scriptname.c instead of scriptname.cgi.

Extended Keyboard Server Mac OS X (10.4.8)

Mar 1, 2007 11:27 AM in response to RedRhubarb

Many thanks, I dropped a .pl file into /Library/WebServer/CGI-Executables and now I can call it from an HTML file in one of my domains. Many Thanks!

A related question: How do I allow individual webmasters to put stuff in their private /cgi-bin/ directories? Right now domain.com/cgi-bin/foo.pl fails if foo.pl isn't in /Library/WebServer/CGI-Executables

Putting them in a /scripts/ directory results in the text of the .pl file being displayed in the browser instead of being executed.

[Or do I want to only allow global cgi files that have been authorized?]

Thanks!

Mar 1, 2007 9:37 AM in response to wpns

The global CGI directory may be empty if you are on a new server. Older versions of Mac OS X may have a test.pl file.

You can find commonly used CGIs on the web. If you want FormMail, Matts' Script Archive has it. The site has been around for more than a decade, so most of the other scripts may not work with newer servers and/or they may not be as secure as scripts rewritten for Perl 5.
http://www.scriptarchive.com/

Another source is the NMS project. They've taken Matt's scripts and have rewritten them for more modern servers.
http://nms-cgi.sourceforge.net/

I recommend learning a little Perl and checking the code before using it on a production server.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Where is /cgi-bin/ and who puts files in it?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.