Find the answer to your Linux question:
Results 1 to 3 of 3
Hi there, I am having a bit of a play with Apache and I want to setup my cgi-bin directory to run scripts The server is working fine but I ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux User Allblack's Avatar
    Join Date
    May 2003
    Location
    Godzone
    Posts
    416

    Configuring cgi-bin


    Hi there,

    I am having a bit of a play with Apache and I want to setup my cgi-bin directory to run scripts

    The server is working fine but I cannot execute scripts. I receive the following error in my log file
    Code:
    malformed header from script Bad Header = Hello World :hello.pl
    I guess the script might be wrong but when I execute the script with
    perl hello.pl it works fine.

    Code:
    #!/usr/bin/perl
    print "Hello World\n";
    I tried it with html included but it did not make a difference.
    Do I need to set the owner/group to the Apache user?

    Here is some of my config options:

    Default Directory
    Code:
    <directory>
    Options FollowSymLinks ExecCGI
    Allow Override None
    </directory>
    My scriptalias
    Code:
    ScriptAlias /cgi-bin/ "/usr/local/apache/cgi-bin/"
    The script alias directory
    Code:
    <directory "/usr/local/apache/cgi-bin">
    AllowOverride None
    Options ExecCGI
    Order allow,deny
    Allow from All
    </directory>

    My directory and scripts are set to 777 for testing.
    I am on a journey to mastering Linux and I got a bloody long way to go!!!

  2. #2
    Linux Engineer
    Join Date
    Jan 2003
    Location
    Lebanon, pa
    Posts
    994
    It is because you are not sending an http header from the script. I suggest using the CGI perl module which will make it very simple to write cgi scripts. You can get the module at www.cpan.org or using perl -MCPAN -e shell.

  3. #3
    Linux User Allblack's Avatar
    Join Date
    May 2003
    Location
    Godzone
    Posts
    416
    Thanks for the reply.
    I added

    Code:
    print "Content-type &#58; text/html\r\n\r\n";
    and it worked fine. I'll definitely will look at the modules

    Cheers
    I am on a journey to mastering Linux and I got a bloody long way to go!!!

Posting Permissions

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