<div dir="ltr">Lonnie,<div><br></div><div>Phew -- yep, this is why I hate this error.</div><div><br></div><div>Try this:</div><div>/----start of script----/</div><div><div>#!/usr/bin/env python</div><div># -*- coding: UTF-8 -*-</div><div><br></div><div># enable debugging</div><div>import cgitb</div><div>cgitb.enable()</div><div><br></div><div>print "Content-Type: text/plain;charset=utf-8"</div><div>print</div><div><br></div><div>print "Hello World!"</div></div><div><br></div><div>----/end of script/----</div><div><br></div><div>Your script and this one (call it test.py) should both be executable, owned by the same user, and in the user's cgi-bin directory.</div><div><br></div><div>Ensure you can run both from the command line, then try to run them in apache by connecting with a browser.</div><div><br></div><div>If test.py works, but your foo.py script doesn't, the problem is in your foo.py script.  Make sure your script is outputting a content-type line (see above).</div><div><br></div><div>If the test.py does not work, we have a configuration issue.</div><div><br></div><div>Could also add a "SetHandler:  cgi-script" to your cgi-directory stanza.</div><div><br></div><div>BTW: which version of apache? 2.2 or 2.4 (some declarations changed between these two version numbers)</div><div><br></div><div><br></div><div>David-</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 7, 2014 at 6:17 PM, Lonni J Friedman <span dir="ltr"><<a href="mailto:netllama@gmail.com" target="_blank">netllama@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I definitely have suexec enabled:<br>
[Mon Oct 06 16:09:31.518777 2014] [suexec:notice] [pid 20128] AH01232:<br>
suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)<br>
<br>
Renaming the suexec binary, and retrying didn't really help:<br>
[Tue Oct 07 16:17:15.854011 2014] [cgi:error] [pid 26631] [client<br>
<a href="http://127.0.0.1:55657" target="_blank">127.0.0.1:55657</a>] AH01215: (2)No such file or directory: exec of<br>
'/usr/sbin/suexec' failed<br>
[Tue Oct 07 16:17:15.854671 2014] [cgi:error] [pid 26631] [client<br>
<a href="http://127.0.0.1:55657" target="_blank">127.0.0.1:55657</a>] End of script output before headers: foo.py<br>
<br>
I added a handler to the "<Directory /home/*/public_html/cgi-bin>"<br>
section of my apache config, but that didn't have any impact on the<br>
problem.<br>
<br>
Any other suggestions?<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
On Tue, Oct 7, 2014 at 6:28 AM, David A. Bandel <<a href="mailto:david.bandel@gmail.com">david.bandel@gmail.com</a>> wrote:<br>
> Lonnie,<br>
><br>
> With or without suexec, you will need a handler line:<br>
> AddHandler cgi-script .cgi .py<br>
> (make sure the above line has the pertinent extension, like .py and your<br>
> python script ends in .py)<br>
><br>
> If using suexec, you should see a line in your error_log:<br>
> suEXEC mechanism enabled<br>
><br>
> Your script must be runable by suEXEC user.  You  might find it easier to<br>
> disable suexec (unless you need it).  Just rename the suexec script and<br>
> restart apache and test.  If you the script works but you need suexec<br>
> (because you're going to have lots of users that need to run CGI scripts),<br>
> then you'll need to troubleshoot the suexec mess.<br>
><br>
> David-<br>
><br>
> On Mon, Oct 6, 2014 at 8:55 PM, Lonni J Friedman <<a href="mailto:netllama@gmail.com">netllama@gmail.com</a>> wrote:<br>
>><br>
>> Hi David,<br>
>> I was actually leaning towards some kind of apache configuration<br>
>> issue, but clearly i'm not the expert here, or I would have figured it<br>
>> out myself :)<br>
>><br>
>> To answer your questions:<br>
>> Its a python script that I'm trying to run.<br>
>> $HOME is on the same partition as / (which is the same partition as<br>
>> the apache $DOCROOT).  Its all on a development system, not anything<br>
>> resembling production.<br>
>> The user's UID is greater than 1000.<br>
>> I am using suexec.<br>
>><br>
>> I'd be happy to answer any other questions.<br>
>><br>
>> thanks<br>
>><br>
>><br>
>> On Mon, Oct 6, 2014 at 6:45 PM, David A. Bandel <<a href="mailto:david.bandel@gmail.com">david.bandel@gmail.com</a>><br>
>> wrote:<br>
>> > Lonnie,<br>
>> ><br>
>> > This is one of the most annoying, frustrating errors.  All it says is<br>
>> > that<br>
>> > the script didn't work.  This may be permissions.  It may be your $HOME<br>
>> > mount is non-executable.  Difficult to say.  You didn't say what kind of<br>
>> > script it was (Perl, PHP, shell).  Is the UID of the user greater than<br>
>> > 1000?<br>
>> > Are you using suexec?<br>
>> ><br>
>> > I hate this error.  Will be either one of the permissions issues above<br>
>> > or<br>
>> > some Apache configuration issue (I'm betting on permissions).<br>
>> ><br>
>> > David-<br>
>> ><br>
>> > On Mon, Oct 6, 2014 at 5:57 PM, Lonni J Friedman <<a href="mailto:netllama@gmail.com">netllama@gmail.com</a>><br>
>> > wrote:<br>
>> >><br>
>> >> Howdy folks,<br>
>> >> Any cgi/apach experts still around?  I'm trying to get cgi scripts<br>
>> >> working from $USERDIR on a new Fedora system, and they all fail with<br>
>> >> internal server errors.  In the apache error log, I see:<br>
>> >> [cgi:error] End of script output before headers<br>
>> >><br>
>> >> If I copy the script over to the server $DOCROOT/cgi-bin then it runs<br>
>> >> just fine.  So this proves the script itself isn't the problem.<br>
>> >> Additionally, non-cgi scripts are served just fine from $USERDIR.<br>
>> >> Both the cgi-bin directory and the script itself are executable for<br>
>> >> all users (755).  This is what I've got set in the apache config for<br>
>> >> the USERDIR directory structure:<br>
>> >><br>
>> >> <Directory "/home/*/public_html"><br>
>> >>     AllowOverride FileInfo AuthConfig Limit Indexes<br>
>> >>     Options MultiViews Indexes SymLinksIfOwnerMatch ExecCGI<br>
>> >>     Require method GET POST OPTIONS<br>
>> >> </Directory><br>
>> >><br>
>> >> <Directory /home/*/public_html/cgi-bin><br>
>> >>         AllowOverride Indexes AuthConfig<br>
>> >>         Options ExecCGI<br>
>> >>         SetHandler cgi-script<br>
>> >> </Directory><br>
>> >><br>
>> >><br>
>> >> Anyone know what I'm missing?<br>
>> >><br>
>> >> thanks<br>
>><br>
>><br>
>> --<br>
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
>> L. Friedman                                    <a href="mailto:netllama@gmail.com">netllama@gmail.com</a><br>
>> LlamaLand                       <a href="http://netllama.linux-sxs.org" target="_blank">http://netllama.linux-sxs.org</a><br>
>> _______________________________________________<br>
>> Linux-users mailing list<br>
>> <a href="mailto:Linux-users@linux-sxs.org">Linux-users@linux-sxs.org</a><br>
>> <a href="http://mailman.celestial.com/mailman/listinfo/linux-users" target="_blank">http://mailman.celestial.com/mailman/listinfo/linux-users</a><br>
><br>
><br>
><br>
><br>
> --<br>
> Two things are infinite: the universe and human stupidity; and I'm not sure<br>
> about the the universe. -- Albert Einstein<br>
> Visit my web page at: <a href="http://david.bandel.us/" target="_blank">http://david.bandel.us/</a><br>
><br>
> _______________________________________________<br>
> Linux-users mailing list<br>
> <a href="mailto:Linux-users@linux-sxs.org">Linux-users@linux-sxs.org</a><br>
> <a href="http://mailman.celestial.com/mailman/listinfo/linux-users" target="_blank">http://mailman.celestial.com/mailman/listinfo/linux-users</a><br>
><br>
<br>
<br>
<br>
--<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
L. Friedman                                    <a href="mailto:netllama@gmail.com">netllama@gmail.com</a><br>
LlamaLand                       <a href="http://netllama.linux-sxs.org" target="_blank">http://netllama.linux-sxs.org</a><br>
_______________________________________________<br>
Linux-users mailing list<br>
<a href="mailto:Linux-users@linux-sxs.org">Linux-users@linux-sxs.org</a><br>
<a href="http://mailman.celestial.com/mailman/listinfo/linux-users" target="_blank">http://mailman.celestial.com/mailman/listinfo/linux-users</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe. -- Albert Einstein<br>Visit my web page at: <a href="http://david.bandel.us/" target="_blank">http://david.bandel.us/</a>
</div>