[Chugalug] OT maybe, python and apache

Dan Lyke danlyke at flutterby.com
Tue Nov 13 16:33:24 UTC 2012


On Tue, 13 Nov 2012 10:21:38 -0600
Garrett Gaston <garrett85 at hotmail.com> wrote:
> I have one copy of the file in /var/www and another
> in /var/www/cgi-bin. I've also used grep and vi to find and edit
> every file in /etc/apache2 that contains "ExecCGI' and I've removed
> that # in front of it hoping to turn on apache's cgi function. Could
> someone please tell me what I've done wrong here? Thanks.

Two problems, one of which I know what the answer to is. Let's start
with the unknown one first: Your Apache isn't running your app as a
CGI. I do something like:

	ScriptAlias /cgi-bin/ /home/danlyke/websites/flutterby.net/cgi-bin/
	<Directory "/home/danlyke/websites/flutterby.net/cgi-bin">
		AllowOverride None
		Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
		Order allow,deny
		Allow from all
	</Directory>


To make http://localhost/cgi-bin/test.py run
from /home/danlyke/websites/flutterby.net/cgi-bin/

The second is easy:

> #!/usr/bin/python3
> print('Content-type: text/plain')

You need a blank line between the headers and the content, so add a
line here that says:

print('')
> # prints an empty line, to end the headers
> print('Testing Python CGI')

Dan


More information about the Chugalug mailing list