Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 16
Hi, I'm using Apache/2.0.40 on Redhat 9. I'm trying to figure out how to permit CGI script outside of ScriptAlias directories. I added following code to my httpd.conf file: ScriptAlias ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jan 2004
    Posts
    93

    Apache CGI error.


    Hi,
    I'm using Apache/2.0.40 on Redhat 9. I'm trying to figure out how to permit CGI script outside of ScriptAlias directories. I added following code to my httpd.conf file:


    ScriptAlias /cgi-bin/ /var/www/cgi-bin/

    <IfModule mod_cgid.c>
    #
    # Additional to mod_cgid.c settings, mod_cgid has Scriptsock <path>
    # for setting UNIX socket for communicating with cgid.
    #
    Scriptsock run/httpd.cgid
    </IfModule>

    ...

    #
    # "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
    # CGI directory exists, if you have that configured.
    #
    <Directory "/var/www/cgi-bin">
    AllowOverride None
    Options +ExecCGI
    Order allow,deny
    Allow from all
    </Directory>

    ...

    #
    # AddType allows you to add to or override the MIME configuration
    # file mime.types for specific file types.
    #
    AddType application/x-tar .tgz

    #
    # AddHandler allows you to map certain file extensions to "handlers":
    # actions unrelated to filetype. These can be either built into the server
    # or added with the Action directive (see below)
    #
    # To use CGI scripts outside of ScriptAliased directories:
    # (You will also need to add "ExecCGI" to the "Options" directive.)
    #
    AddHandler cgi-script .cgi .pl

    <Directory "/home/*/public_html/cgi-bin">
    Options +ExecCGI
    </Directory>


    And I put "test.cgi" file in my /home/david/publlic_html/cgi-bin directory:

    #!/usr/bin/perl
    print "Content-type: text/html\r\n\r\n";
    print "Hello, World.";


    Here is the error message I got:

    Server error!

    The server encountered an internal error and was unable to complete your request.

    Error message:
    Premature end of script headers: blah.cgi

    If you think this is a server error, please contact the webmaster

    Error 500
    ...

    I checked the permissons and everything I could but still couldn't figure out why. Can anyone help me?

  2. #2
    Linux Newbie
    Join Date
    Aug 2001
    Location
    USA, Texas
    Posts
    217
    Try usiing the following code and see what happens.

    Code:
    #!/usr/bin/perl -w
    
    use CGI;
    
    $cgi = new CGI&#40;&#41;;
    
    print $cgi->header&#40;&#41;,"\n";
    print $cgi->start_html&#40;&#41;,"\n";
    print "hello world";
    print $cgi->end_html&#40;&#41;,"\n";
    [ [ SykkN alloc ] initWithThePowerTo: destroyYouAll ];
    /* Don\'t make me use it! */

  3. #3
    Just Joined!
    Join Date
    Jan 2004
    Posts
    93
    sykkn,
    I got the same error message. The strange thing is even if I don't put anything
    in test.cgi except for #!/usr/bin/perl -w, I still get the same result.

  4. #4
    Linux User
    Join Date
    May 2003
    Location
    CA
    Posts
    370
    have you uncommented out the following line

    AddHandler cgi-script .cgi

    if not then uncomment it out and restart the webserver and give it a shot.
    Fixing Unix is better than working with Windows.
    http://nikhilk.homedns.org/projects/index.html

  5. #5
    Linux Newbie
    Join Date
    Aug 2001
    Location
    USA, Texas
    Posts
    217
    OK, sorry that didn't help just wanted to make sure that code I knew worked still didn't work for you.

    I have found people saying they got that error due to permissions. Specifically write/execute permissions for users other than yourself. What are your current permissions? Try chmod'ing to 711 and see if that works for you.

    I'll keep researching until I hear back.
    [ [ SykkN alloc ] initWithThePowerTo: destroyYouAll ];
    /* Don\'t make me use it! */

  6. #6
    Linux User
    Join Date
    May 2003
    Location
    CA
    Posts
    370
    if you run it from the command line, does it work correctly?
    try uncommenting the line if its commented:
    AddHandler cgi-script .cgi

    Also you might want to check out this link:
    http://perlmonks.thepen.com/24447.html
    Fixing Unix is better than working with Windows.
    http://nikhilk.homedns.org/projects/index.html

  7. #7
    Just Joined!
    Join Date
    Jan 2004
    Posts
    93
    Yes, I did uncomment the "AddHandler cgi-script .cgi" line. And I set my permission to 755. I ran the script on command line and everything looks fine. Plus, I put the script in /var/www/cgi-bin/ directory and it ran fine there as well. The "Server error!" message is still there. I'm lost

  8. #8
    Linux User
    Join Date
    May 2003
    Location
    CA
    Posts
    370
    hmmm....
    what happens if you put
    Options ExecCGI
    instead of
    Options +ExecCGI
    without the "+"

    just trying out all possible avenues here...dont know if it might make
    a difference but its worth a try....
    Fixing Unix is better than working with Windows.
    http://nikhilk.homedns.org/projects/index.html

  9. #9
    Just Joined!
    Join Date
    Jan 2004
    Posts
    93
    nikhil,
    I tried it and it's still not working.

  10. #10
    Linux Newbie
    Join Date
    Aug 2001
    Location
    USA, Texas
    Posts
    217
    I read that you need different permisions to use the scripts is your public_html directory. Trying chmod'ing to 711 and running it and then try 770 and running it.
    [ [ SykkN alloc ] initWithThePowerTo: destroyYouAll ];
    /* Don\'t make me use it! */

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •