I’ve been playing around with making my mac a webserver, and now I’m trying to make a simple html form, and a perl script that prints out the input. I have /Library/WebServer/Documents symlinked to ~/Sites/, so I have my index.html and display.cgi both there. But when I press submit, the perl file just shows up as text. Any cgi file I have doesn’t execute, it just shows up as text. What am I doing wrong? Thanks.
Share
Unless your server is specifically set up to run perl scripts in the
/Library/WebServer/Documentsfolder, you’ll have to put them in/Library/WebServer/CGI-Executablesinstead. (And then access them from the/cgi-bin/path in the URL, e.g.http://localhost/cgi-bin/display.cgi.)Once you’ve done that, make sure that you’ve set the permissions on the Perl script so that it’s executable. To do this, go to the containing directory in Terminal, and type
chmod a+x display.cgi.Also, check that the first line of the script (the shebang line) has the correct path to perl. On my Mac, Perl is located at
/usr/bin/perl, but if you want to check for yourself then run the commandwhich perl.