Re: Help getting Perl/CGI running on OS X localhost with apache



wrote:

> Hi John,
>
> Thanks for the reply. Unfortunately it went over my head. Could you
> clarify a few points
>
>>> The only difference from that webpage is my configure file will
> parse
>>> ".shtml" files instead of ".html" files.
>
>>shtml = SSI, not CGI
>
> Will this affect my first.cgi test since i am directing my browser to
> the actual cgi file? So what should I do?

..shtml is parsed HTML, you can call a script using SSI directives.

cgi is more commonly used like:

http://example.com/cgi-bin/helloworld.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.
>
> My sites folder is "/users/peter/Sites". What should the cgi-bin
> directory be?

if you put index.html in Sites, and you see the index.html if you go to
http://localhost/ your document root is /users/peter/Sites. More safe:
search in your httpd.conf for DocumentRoot and check its value.

> I cannot understand what you complete first.cgi file would be with the
> modifications you have suggested.

/usr/bin/perl -T

use strict;
use warnings;

print <<HELLO;
Content-type: text/plain

Hello, World!
HELLO

(untested)

> I have seen other hello world files
> like mine suggested on the internet. I'm surprised that you seem to
> say it is not even close to correct.

This holds for an amazing number of CGI scripts you will find. Most will
be extremely badly written. A huge number are developed using trial and
error, which often means: find a script, change lines until it works,
make it available. In short, most scripts you find are insecure, garbage
and an extremely bad start for anyone wanting to learn CGI.

> I do not understand "make a cgi-bin directory in the *parent* of your
> Document Root, e.g....". Where would cgi-bin and htdocs be in relation
> to "/users/peter/Sites"?

/users/peter/cgi-bin

> Sorry, I guess I need a bit more hand holding to get started. But I am
> really interested.

Normally Apache set up questions should be asked in an Apache related
group.

Oh, and cgi-bin should be readable by your Apache process. 711 often
does the trick. If you can turn one 1 into 0, do so. (Same for the 5 in
755, if you can turn a 5 in a 0 do so).

--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html

.



Relevant Pages

  • Re: dynamic lib ignored even after "found" in "install_driver(Oracle) failed: Cant load..." cgi prob
    ... the solution i found is this: i moved the directory containing libclntsh.so under /usr/lib, which is a location that apache seems to trust, as opposed to where i had originally placed this directory. ... so, if i knew then what i know now, here are the steps _I_ would use were i to install the oracle instantclient such that the DBD::Oracle module would work when used in an apache 2.0 CGI: ... i also could run it this way by placing tnsnames.ora in my home directory as .tnsnames.ora, but this location will do me no good when i want apache to run the script as a cgi. ... am i missing some sort of configuration detail regarding apache and permissions granted a cgi? ...
    (perl.dbi.users)
  • Re: Apache Security Issue: File Access
    ... > I just recognized that with Apache configured for VirtualHosts, ... > - no one can ready files using a file system call in CGI or ASP ... Does the target program name have a / or .. ... Does the user who owns the target script exist on the system? ...
    (comp.security.unix)
  • Re: Rivet and snit....
    ... You will need to set up Apache to make sure your directories are ready ... to execute CGI (if you plan to say turn your welcome page into a CGI ... script to generate the page). ... indicate it's intent - then process it as a form submission script. ...
    (comp.lang.tcl)
  • Re: PHP and MySQL passwords
    ... I'll assume your on a linux system with apache as your webserver. ... If it is shared is PHP running as a module or cgi? ... If you code the user/pass in a file anyone with an account on the ... file either by reading it directly or by writing a script to read it. ...
    (alt.php)
  • Cant setup mod_perl and DBD::Sybase
    ... I've been using DBD::Sybase with CGI scripts. ... I thought that perhaps I needed to set up $SYBASE from Apache, ... The fact is that if I call the perl script from a shell script and then ... Director de Sistemas de Información ...
    (perl.dbi.users)