Tag Archives: cgi-bin

End of script output before headers – No such file or directory: exec of

 

[Wed Jul 19 16:08:45.679229 2017] [cgi:error] [pid 2954] [client 94.63.xxx.xxx:12439] End of script output before headers:4KUYWRBjpMFod9i.cgi
[Wed Jul 19 16:09:05.030839 2017] [cgi:error] [pid 783] [client 94.63.xxx.xxx:37260] AH01215: (2)No such file or directory: exec of ‘/home/webroot/nasamos.com/www/cgi-bin/x9uWvwAREeUkQn5p/4KUYWRBjpMFod9i.cgi’ failed

Well!,
I saw a few blog posts and forum threads about this issue, but NONE was able to help me….

Yah!, syntax was okay….

perl -c 4KUYWRBjpMFod9i.cgi
4KUYWRBjpMFod9i.cgi syntax OK

I’v created a brand new file on /cgi-bin/ with some dummy filename and pumped a simple perl script on it…

#!/usr/bin/perl
# hello.pl -- my first perl script!
print "Content-type: text/html\n\n";
print "Hello, world!\n";

I was able to run it successfully, so…. the issue wasn’t on the CGI/PERL/APACHE/FIREWALL/SUEXEC.
I guess that the 4KUYWRBjpMFod9i.cgi had some issue… even using file -i  it looked to be okay… I’v decided to copy the content of 4KUYWRBjpMFod9i.cgi to the new dummy cgi file … and it worked….

I guess that the issue was on the encoding of the original cgi…

Can’t locate CGI/Carp.pm in @INC & Can’t locate LWP/Simple.pm in @INC

 

[Thu Mar 09 02:23:43.435879 2017] [cgi:error] [pid 28444] [client 94.63.XXX.XXX:54192] AH01215: Can’t locate CGI/Carp.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /path/to/cgi/admin/admin.cgi line 31.

This solved my issue…

yum install perl-CGI

 

[Thu Mar 09 02:26:54.892385 2017] [cgi:error] [pid 28442] [client 94.63.XXX.XXX:54242] AH01215: [Thu Mar 9 02:26:54 2017] admin.cgi: [Thu Mar 9 02:26:54 2017] admin.cgi: Can’t locate LWP/Simple.pm in @INC (@INC contains: /path/to/cgi/admin/ /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at ./shared/subs3.pm line 1003.
[Thu Mar 09 02:26:54.892456 2017] [cgi:error] [pid 28442] [client 94.63.XXX.XXX:54242] AH01215: [Thu Mar 9 02:26:54 2017] admin.cgi: [Thu Mar 9 02:26:54 2017] admin.cgi: BEGIN failed–compilation aborted at ./shared/subs3.pm line 1003.
[Thu Mar 09 02:26:54.892599 2017] [cgi:error] [pid 28442] [client 94.63.XXX.XXX:54242] AH01215: [Thu Mar 9 02:26:54 2017] admin.cgi: Compilation failed in require at /path/to/cgi/admin/admin.cgi line 151.

This solved my issue!

yum install perl-XML-Simple

 

Enabling cgi-bin on apache

I had to enable CGI on this new recent server

sudo a2enmod cgi
sudo service apache2 restart

Simple!,
But I was getting a error script not found or unable to stat

[Mon Nov 30 18:00:32.380748 2015] [cgi:error] [pid 18799] [client 84.91.XXX.XXX:62545] script not found or unable to stat: /usr/lib/cgi-bin/HiPGZ23est4

I had to edit the .conf file

nano /etc/apache2/sites-enabled/domain.com.conf

and add the following lines

ScriptAlias /cgi-bin/ /path_to_cgi_folder/cgi-bin/
<Directory "/path_to_cgi_folder/cgi-bin/">
 AllowOverride None
 Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
 Order allow,deny
 Allow from all
</Directory>

and then reload the apache configurations

service apache2 reload