Results 1 to 3 of 3

Thread: Apache cgi-bin: malformed header from script. Bad header=this is a test : test.pl

  1. #1
    Junior Member
    Join Date
    Jun 2011
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default Apache cgi-bin: malformed header from script. Bad header=this is a test : test.pl

    installed apache
    Code:
    [root@server1~]# yum install httpd* -y
    
    [root@server1~]# service httpd start
    Starting httpd:            [   OK   ]
    [root@server1~]# chkconfig httpd on
    create a file index.html in '/var/www/html/'
    Code:
    [root@server1~]# vim /var/www/html/index.html
    <center><h1>This is server1 Domain</h1></center>
    :wq
    modified httpd.conf
    Code:
    [root@server1~]# vim /etc/httpd/conf/httpd.conf
    
    uncommented the line 'NameVirtualHost'
    NameVirtualHost 172.24.0.254:80
    
    made a entry
    <VirtualHost 172.24.0.254:80>
        DocumentRoot /var/www/html
        ServerName server1.example.com
        ErrorLog logs/example.com-error_log
        CustomLog logs/example.com-access_log common
    </VirtualHost>
    :wq
    restart the service
    Code:
    [root@server1~]# service httpd restart
    Stopping httpd:            [   OK   ]
    Starting httpd:            [   OK   ]
    chkd in firefox and in entire domain its working fine


    now triying to configure cgi-bin script
    Code:
    [root@server1~]# vim /var/www/cgi-bin/test.pl
    #!/usr/bin/perl
    print "This is a test \n"
    :wq
    changed the permession
    Code:
    [root@server1~]# chmod +x /var/www/cgi-bin/test.pl
    chkd by running the script its working fine
    Code:
    [root@server1~]# /var/www/cgi-bin/test.pl
    This is a test
    
    [root@server1~]# perl /var/www/cgi-bin/test.pl
    This is a test
    now updated the 'httpd.conf' file.
    Code:
    [root@server1~]# vim /etc/httpd/conf/httpd.conf
    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
    
    modified the "virtual host" directive
    <VirtualHost 172.24.0.254:80>
        DocumentRoot /var/www/html
        ServerName server1.example.com
        ErrorLog logs/example.com-error_log
        CustomLog logs/example.com-access_log common
    <Directory /var/www/cgi-bin>
        AddHandler test .pl .cgi
        AllowOverride None
        Options ExecCGI
        Order allow,deny
        Allow from all
    </Directory>
    </VirtualHost>
    :wq
    restart the service
    Code:
    [root@server1~]# service httpd restart
    Stopping httpd:            [   OK   ]
    Starting httpd:            [   OK   ]
    but now when im trying to execute the script in the web browser (firefox). its showing error


    Internal Server Error

    The server encountered an internal error or misconfiguration and was unable to complete your request.
    Please contact the server administrator, root@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.
    More information about this error may be available in the server error log.
    ________________________________________
    Apache/2.2.15 (Red Hat) Server at server1.example.com Port 80

    Getting Error in logs also.
    Code:
    [root@server1~]# tail -f /var/log/httpd/error_log
    [Fri Mar 02 17:02:29 2012] [error] [client ::1] malformed header from script. Bad header=this is a test : test.pl
    tried my install "mod_perl" package but the same issue persists.
    Code:
    [root@server1~]# yum install mod_perl* -y
    Please help..!!

  2. #2
    Never say die nixcraft's Avatar
    Join Date
    Jan 2005
    Location
    BIOS
    Posts
    4,513
    Thanks
    17
    Thanked 804 Times in 511 Posts
    Rep Power
    10

    Default

    First, send content type as "text/html" from perl script:
    Code:
    #!/usr/bin/perl
    print "Content-type: text/html\n\n"; 
    print "This is a test \n";
    Make sure test.pl has executable permissions:
    Code:
    chmod +x /var/www/cgi-bin/test.pl
    All [Solved] threads are closed by mods / admin to avoid spam issues. See Howto mark a thread as [Solved]


  3. The Following User Says Thank You to nixcraft For This Useful Post:

    anas_lko (2nd March 2012)

  4. #3
    Junior Member
    Join Date
    Jun 2011
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    Well Thanks alot nix craft... this is really very helpfull.. and the problem has been resolved...

    but i just want to know we can only execute perl script via cgi-bin or can we execute shell scripts also..?? if ys then can you please let me know how we can execute shell scripts..??

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Lighttpd oversized header ?
    By maxtox in forum Web servers
    Replies: 3
    Last Post: 10th September 2011, 06:14 AM
  2. Replies: 2
    Last Post: 4th December 2010, 02:34 PM
  3. Advice, how to create Post header in squid
    By asafbs in forum Linux software
    Replies: 0
    Last Post: 4th September 2010, 07:36 AM
  4. extrnal header
    By cant in forum Shell scripting
    Replies: 1
    Last Post: 4th August 2010, 08:26 PM
  5. Net-snmp header file
    By puppen in forum Linux software
    Replies: 2
    Last Post: 23rd May 2006, 05:45 PM

Tags for this Thread

Posting Permissions

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