[Tutor] Simple CGI script and Apache configuration
Martin Walsh
mwalsh at mwalsh.org
Tue Feb 24 19:13:32 CET 2009
wormwood_3 wrote:
> I wasn't sure if that was needed, so I took it out, sorry about that. I put
>
> ScriptAlias /cgi-bin/ "/var/www/samuelhuckins.com/cgi-bin/"
>
> in place, reloaded, and it works! I think the problem throughout was
> that I was mixing up what was necessary between CGI and mod_python.
The apache2 documentation isn't clear about the relationship between
ExecCGI and ScriptAlias (rather, it's not clear to me) and unless I've
missed something, seems to imply that either ScriptAlias or ExecCGI
alone should be sufficient. Unfortunately, I don't have time to
experiment. IIRC, all of the vanilla apache configs I've worked with
recently include both in definitions for cgi-bin.
In any case, glad it worked.
>
> If you'd like a random programming epigram served up by this new config,
> check out: http://samuelhuckins.com/cgi-bin/qotd.py
Very cool, thanks.
>
> -Sam
> wormwood_3 wrote:
>> Thanks for all the suggestions! I tried to go through them, and will
>> relate what results I encountered. I changed my Apache config to:
>>
>> <Directory /var/www/samuelhuckins.com/cgi-bin/>
>> AllowOverride None
>> Options ExecCGI
>> Order allow,deny
>> Allow from all
>> </Directory>
>>
>> I in fact did not have the cgi module enabled, so I did that. Then I ran
>> "sudo /etc/init.d/apache2 reload", and hit
>> http://samuelhuckins.com/cgi-bin/hello.py, which contains simply:
>>
>> #!/usr/bin/python
>> print "Content-type: text/html"
>> print
>> print "<html>"
>> print "<center>Hello!</center>"
>> print "</html>"
>>
>> I get prompted to download the file, but it does not execute or appear
>> in plain text. The logs just show the request being made. What is the
>> missing element to get this script to execute?
>>
>
> When you look at the downloaded file, is it your python script?
>
> Looks like you changed the path where you're keeping your cgi script,
> did you update the ScriptAlias directive to suit?
>
> You may find this more helpful ...
> http://httpd.apache.org/docs/2.0/howto/cgi.html
>
More information about the Tutor
mailing list