3

I just started learning how to use Python MapScript for MapServer so I am trying very mininal example just to see how it works. My code is:

#!/usr/bin/env python

import mapscript

mapfile = "/path/to/mapfile/mapfile.map"

mapobject = mapscript.mapObj(mapfile)

mapobject.draw()

I am writing this on Spyder 2 and I runs correctly. I then put it in /usr/lib/cgi-bin folder and try to run it on my browser with this link:

http://localhost/cgi-bin/file.py

The browser throws me the following error:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

 Please contact the server administrator at webmaster@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

 More information about this error may be available in the server error log.

And the error log only shows this:

[pid 1353] [client ::1:56156] End of script output before headers: file.py

Now how can I know what the error is? Is it right that I am putting it in /usr/lib/cgi-bin ?

EDIT: I've also set my apache2.conf file a section like this:

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory /usr/lib/cgi-bin/>
   Options +Indexes +ExecCGI +FollowSymLinks
   AddHandler cgi-script .py .cgi
   AllowOverride None
   Require all granted
</Directory>
  • It is correct to have the file in your server CGI-BIN folder – nmtoken Apr 20 '17 at 6:30
  • You mean.. make a cgi-bin in /var/www/html ? There isn't any cgi-bin folder there? Which one you mean ? – Stefanos Apr 20 '17 at 10:43
  • I meant wherever it is mapped on your web server, rather than being specific that it has to be /usr/lib/cgi-bin – nmtoken Apr 20 '17 at 11:15
  • How can I find which one is this ? – Stefanos Apr 20 '17 at 17:26
  • What does it say in your Apache conf (or other web server configuration file)? – nmtoken Apr 20 '17 at 17:30
1

I simply add this line before the import

print "Content-type: text/html\n\n";

as detailed in this topic in Perl : Link to Stackoverflow

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.