简体   繁体   中英

perl cgi “End of script output before headers”

Could anyone help me with this? This one bugs me for couple days...

environment:
running a simple perl cgi script on fedora 21,
Server version: Apache/2.4.10 (Fedora),
This is perl 5, version 18, subversion 4 (v5.18.4) built for x86_64-linux-thread-multi,
getenforce: Permissive

the cgi script:

#!/usr/bin/perl
print "Content-type: text/html\n\n";

use strict;
use warnings;
print "Hello, world!<br />\n";

foreach my $key (keys %ENV) {
    print "$key --> $ENV{$key}<br />";
}


problem:
the script won't run in 127.0.0.1/~username/subfolder/
I should knew how to setup perl-cgi environment, and the same code works on 127.0.0.1/cgi-bin, 127.0.0.1/cgi-bin/subfolder/, 127.0.0.1/~username/

I always get "End of script output before headers" when execute script under user's subfolder.
Could anyone helps? Thanks

We can't diagnose your problem without further detail because what that error means is that apache didn't get that far with running your script.

Now, as that's the first line of your script, it's likely that means apache couldn't run it at all.

Usual culprits for this are:

  • script not executable
  • code otherwise broken such that it doesn't compile with perl -c .

The solution would be to check your apache logs which would capture STDERR from when this is happening, and that'll help you diagnose it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM