Re: Help getting Perl/CGI running on OS X localhost with apache
- From: John Bokma <john@xxxxxxxxxxxxxxx>
- Date: 10 May 2005 17:35:08 GMT
wrote:
> Hi,
>
> I am trying to learn about perl and cgi. I have apache and php running
> on my OS X (10.3) localhost. I followed the instructions on the
> following site to configure apache for perl my modifying the file
> "/etc/httpd/httpd.conf" on my computer.
>
> http://www.cgi101.com/book/connect/mac.html
>
> The only difference from that webpage is my configure file will parse
> ".shtml" files instead of ".html" files.
shtml = SSI, not CGI
> I have written a file called "first.cgi" and saved it in my sites
> folder.
Use a cgi-bin dir *outside* your document root.
> #!/usr/bin/perl -w
use warnings; # instead of -w
use strict;
Also, use -T.
> print "Content-type: text/html\n\n";
Be careful with printing your own headers...
You can use <<HERE docs, eg.
print <<HELLO;
Content-type: text/plain
Hello, World!
HELLO
(note that what you served was not valid HTML, hence I changed the
content-type to plain).
> The forbidden message did not go away. What's going wrong? Is apache
> not configured correctly? Do i need any extra files in my sites
> folder?
make a cgi-bin directory in the *parent* of your Document Root, e.g.
cgi-bin
htdocs
next you need:
ScriptAlias /cgi-bin/ "/absolute/path/to/cgi-bin/"
<Directory "/absolute/path/to/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
Note that the second path has *no* trailing / and the first *has*.
If you are serious in developing stuff I recommend using virtual hosts,
see: http://johnbokma.com/mexit/2005/01/05/apache-httpd-conf-split.html
Check your error_log, I often use:
tail -f logs/error_log
HTH,
--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
.
- Follow-Ups:
- Re: Help getting Perl/CGI running on OS X localhost with apache
- From: petermichaux
- Re: Help getting Perl/CGI running on OS X localhost with apache
- References:
- Help getting Perl/CGI running on OS X localhost with apache
- From: petermichaux
- Help getting Perl/CGI running on OS X localhost with apache
- Prev by Date: Help getting Perl/CGI running on OS X localhost with apache
- Next by Date: Re: Help getting Perl/CGI running on OS X localhost with apache
- Previous by thread: Help getting Perl/CGI running on OS X localhost with apache
- Next by thread: Re: Help getting Perl/CGI running on OS X localhost with apache
- Index(es):
Relevant Pages
|