httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bob Cole <bobc...@mac.com>
Subject [users@httpd] Enabling CGI on Apache 2.2 on Mac OS X 10.6.4
Date Mon, 30 Aug 2010 15:42:25 GMT
Diego,
I, too, am learning about cgi programs on Mac OS X 10.6.4. Here are the steps I follow.

1) First, create a program file in the /Library/WebServer/CGI-Executables folder.
Here is one that I find helpful. Put the following into a file such as myenvvars.pl
     #!/usr/bin/perl
     print "Content-type: text/html\n\n";
     foreach $key (keys %ENV) {
        print "$key --> $ENV{$key}<br>";
     } 

If you prefer to use php, here is a similar program you might call myglobalvars.php
     #!/usr/bin/php
     <?php
     print "Content-type: text/html\n\n";
     print "<font size=\"1\" face=\"Arial\">";
     print "GLOBALS Variables:";
     foreach($GLOBALS as $key=>$value) {
         print "<br />\$GLOBALS[\"$key\"] == $value";
         print "<br />Count: " . count($GLOBALS[$key]);
     }
     print "</font>";
     ?>

2) Using the Terminal program, change directory to
     cd /Library/WebServer/CGI-Executables
then list the contents:
     ls -l
and make sure the permissions are set so the file may be executed (rwxr-xr-x).
If not, then change the permissions with 
     chmod a+x myenvvars.pl  (or you could use chmod 755 myenvvars.pl).

3) access the cgi file with a browser:
	http:/localhost/cgi-bin/myenvvars.pl

The Console program is in the /Applications/Utilities folder.  With that program you can look
at the Apache access and error log files (click the triangle next to /private/var/log).
The Apache httpd.conf file is in the /etc/apache2/ directory.
I have not tried to change the location of the CGIs so I can't help with that aspect of your
question.  

HTH,
Bob


--- Original Message ---
From: Diego Sebastián Birch <dsbirch69@hotmail.com>
Date: August 30, 2010 8:48:44 AM CDT

Hello everyone,
I've recently started developing applications on a Mac OS X, and one of them is a migration
from a C++ CGI written for MS Windows. Porting it has been more or less fine, but I'm stuck
with actually executing my program as a CGI. All I have managed to do is download my binary
image several times.
Unfortunately, I am new to Mac OS / POSIX / Apache development, although I have a fair knowledge
of similar concepts on MS Windows running IIS.
So far, what I have done is:1) Write a small application that outputs "HTTP/1.0 200 OK\r\nContent-type:
text/plain\r\nContent-length: 33\r\n\r\nProbando un CGI superchorra" (which is Spanish for,
more or less, "testing a really silly CGI") to the standard output.2) Build it and place the
executable file in "/Library/WebServer/CGI-Executables"3) Attempt to access the file viahttp://localhost/cgi-bin/testcgi.cgi
After spending a few hours trying different things I've read in different places, without
really knowing what I was doing, I have managed to either download a binary image of the file,
or get an HTTP 500 error, but I don't even know where to look for the log files in order to
try to analize the cause.
Would anyone be so kind as to explain to me what steps I need to take in order to enable CGIs
on a specific user folder, taking into account Apple's efforts in hiding all configuration
files and such from me?
Thanks for the time taken to read this, and for whatever time you might take in trying to
help me.
Best regards,
Diego 


Mime
View raw message