.cgi script outside cgi-bin

Discussion in 'Installation/Configuration' started by bburn, May 27, 2007.

  1. bburn

    bburn New Member

    Hello,

    i try to run a cgi script outside of the cgi-bin dir.

    Can you please tell me how to make it?

    Regards,

    Bjoern
     
    Last edited: May 27, 2007
  2. falko

    falko Super Moderator Howtoforge Staff

    Add a line like this to your Apache Directives field in ISPConfig:

    Code:
    ScriptAlias  /cgi-bin/ /path/to/your/cgi-bin_directory/
     
  3. bidevi

    bidevi New Member

    This got cgi-scripts running outside the cgi-bin for me

    To get cgi-scripts running somewhere outside the cgi-bin I did the following things.

    In httpd.conf, somewhere halfway the file, I found a paragraph saying:

    <Directory "/var/www/icons">
    Options Indexes MultiViews
    AllowOverride
    Order allow,deny
    Allow from all
    </Directory>

    The above isn't important for what you want, but I just chose this as a spot below which in my case I added some new lines.

    Let's assume that you want to run a cgi-script inside the following directory:

    /var/www/html/eggplant

    Add these lines in the httpd.conf file:

    <Directory "/var/www/html/eggplant">
    Options Indexes MultiViews ExecCGI
    </Directory>

    Restart the Apache server:
    /etc/init.d/httpd restart

    Now you may run cgi-scripts inside the directory eggplant.

    If necessary, repeat the permissions of your working scripts inside the cgi-bin.
     
  4. bidevi

    bidevi New Member

    But now: how to do this in Lenny

    Earlier I wrote how to execute perl scripts in Etch.

    Now I use Lenny. A httpd.conf file does exist but it's empty. I assume one can configure either the file /etc/apache2/sites-available/default or a file like /etc/apache2/sites-available/example1.com.vhost.

    I have tried to repeat the steps written in my earlier post in those files. Also, the permissions for files and folders are wide open (777) but I get either a Forbidden! or a misconfiguration message, depending on my different configuration attempts.

    So I opened /etc/apache2/sites-available/default and found these lines:

    <Directory /var/www/>
    AllowOverride None
    Order allow,deny
    allow from all
    </Directory>

    I added Options Indexes FollowSymLinks ExecCGI to make it look like:

    <Directory /var/www/>
    Options Indexes FollowSymLinks ExecCGI
    AllowOverride None
    Order allow,deny
    allow from all
    </Directory>

    I restarted the server: /etc/init.d/apache2 restart

    I visited example1.com/test.pl

    Result: ERROR 403 - Forbidden!
    The following error occurred:
    You are not permitted to access the reqested URL.
    Please contact the webmaster with any queries.

    I contacted the webmaster. That's me. And I don't know it.

    Inside sites-enabled there is also configuration file example1.com.vhost, containing these lines:

    # cgi enabled
    <Directory /var/www/clients/client1/web1/cgi-bin>
    Order allow,deny
    Allow from all
    </Directory>
    ScriptAlias /cgi-bin/ /var/www/clients/client1/web1/cgi-bin/
    AddHandler cgi-script .cgi
    AddHandler cgi-script .pl

    Now, I told the webmaster not to be lazy and he couldn't refuse because it was me, and in the example1.com.vhost file I changed the lines:

    <Directory /var/www/clients/client1/web1/web>
    Options FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
    </Directory>

    to look like (adding Indexes MultiViews ExecCGI):

    <Directory /var/www/clients/client1/web1/web>
    AddHandler cgi-script .cgi .pl
    Options Indexes FollowSymLinks MultiViews ExecCGI
    AllowOverride All
    Order allow,deny
    Allow from all
    </Directory>

    And then: /etc/init.d/apache2 restart

    After which www.example1.com/test.pl remained Forbidden! as ever.

    And this is what the text.pl files contains:

    #!/usr/bin/perl
    print "Hello World.\n";

    What a terrible day! Please, tell my what's good about Lenny.

    Does anyone know how to run perl scripts in Lenny outside the cgi-bin?

    Thanx in advance.
     
    Last edited: Apr 23, 2010
  5. bidevi

    bidevi New Member

    CGI doesn't work at all

    Thanks, Falco, for your suggestion (in april 2005). I'll try it out later. It took me some effort to figure out that the Apache directives field is under the Options tab of a given domain in ISPConfig3.

    Something funny is going on. I'm using the tandem Lenny/ISPConfig3 now and perl doesn't work at all, not even in the cgi-bin. There was no such problem with my old Etch/ISPConfig combination.

    Since the domain was created using the ISPConfig3 panel: is there something I could have done wrong while creating the site?

    For your information: I checked all boxes except SSL, with Auto-Subdomain set to www. and PHP set to Mod-PHP (and Active checked). I use both PHP and perl.

    If you want to see what happens, go to opstartpagina.nl/opstartmail.html, send me a message and see what comes out of that. The perl script is in the cgi-bin and permissions are wide open.

    If I can't get the new tandem working (I'm configuring it from the top on another box), I'll have to return to the old tandem or resort to another Linux distro.

    OK, perl in cgi-bin is working alright now. No luck yet outside the bin.
     
    Last edited: Apr 24, 2010

Share This Page