Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

website, cgi-bin, different locations???

by Anonymous Monk
on Aug 13, 2004 at 16:41 UTC ( [id://382746]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Is there a good reason why I wouldn't want to have a cgi-bin within my website directory? So far, every recommendation I've come across for setting up a CGI-bin with PERL has included a virtual directory pointing to a directory (ouside the web directory), often on another drive, where the PERL script resides. Is there a special reason for this? Can't I just place the CGI-script in the same folder as the HTML file that called it? Thanks
  • Comment on website, cgi-bin, different locations???

Replies are listed 'Best First'.
Re: website, cgi-bin, different locations???
by dragonchild (Archbishop) on Aug 13, 2004 at 17:42 UTC
    From a technical perspective, there's no reason at all. In fact, some webservers allow you to have your CGI scripts (which don't necessarily have to be written in Perl) on another machine.

    The primary reason most people separate it is to have a separation of concerns - you don't want your business logic mixed in with your display logic.

    The other reason most commonly cited is that it's easier to lock down your cgi-bin directory than it is your htdocs directory. So, there's a small security gain, but not a lot.

    ------
    We are the carpenters and bricklayers of the Information Age.

    Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

    I shouldn't have to say this, but any code, unless otherwise stated, is untested

Re: website, cgi-bin, different locations???
by ikegami (Patriarch) on Aug 13, 2004 at 17:46 UTC
    I'm guessing that historically, cgi files had to be in the cgi-bin directory. Nowadays, at least with Apache, it's just a question of preference. One of the directories on my server is configured such that .jpg files are treated as CGI files. (They're actually perl scripts that generate images, not images.)
Re: website, cgi-bin, different locations???
by csuhockey3 (Curate) on Aug 13, 2004 at 17:05 UTC
    you can but the purpose (at least for me) to use cg-bin is to have a central location for all of your cgis. This makes it easier to re-use scripts common to multiple pages throughout your site. Also nice because you can lock it to protect the scripts.

    -CSUhockey3
Re: website, cgi-bin, different locations???
by nikos (Scribe) on Aug 13, 2004 at 17:06 UTC
    you can place your script anywhere you want. just make sure the webserver you use will execute them. The reason is to keep script separately from html just to be more organized. Sometimes security. In reality usually scripts can easily access the directory with html files as they are run by the webserver under the same user. I keep scripts in the same directory where I keep html files. Blame me other monks, if you think it's not correct.
      no blame -- to each his own I guess. I just prefer the organization and customization of cgi-bin. Especially when the number of scripts gets out of control.


      -CSUhockey3

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://382746]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2024-04-25 15:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found