[mapserver-users] Couldn't run perl mapscript under Apache

Puneet Kishor pkishor at GeoAnalytics.com
Sun Nov 10 10:56:35 EST 2002


Krung,

Note my response below --

On Sunday, November 10, 2002, at 09:05  AM, krung wrote:

> Puneet
>
> As I told you last message, error_log showed no cause except "[Sun Nov 
> 10 22.04.55] [error] [client 127.0.0.1] Premature end of script 
> headers: /map/testmap.pl".


please post not just the last line, but several lines _before_ the last 
line as well. The last line tells you that the ultimate cause of script 
dying was "Premature end of script headers...". However, the lines 
before that will provide the clue as to what led to a premature end.

Do this... tail <your logfile>. Note the timestamp of the last line. 
Run your webpage. Email us all the lines added to the logfile _since_ 
the timestamp you noted above.


> ..
> $map = new mapObj("mapfile.map") or print "couldn't open map file\n";
> unless ($map) { exit;}

here is a better way to replace the above two lines with... all 
accomplished on one line.

# create a new map object
die $mapscript::ms_error->{message} unless $map = new 
mapObj("$mapfile");

> ..
> In line "print 'OK';exit;", I used it to check if openning mapfile had 
> error. It printed 'OK', so it could open mapfile. Then I removed it 
> out and re-run the script. It showed "Internal Server Error" to my 
> browser. Error message I got from error_log in 
> /etc/httpd/logs/error_log and /var/log/httpd/error_log was that I 
> showed you in the beginning of this message.

how can you have two apache logs... you will have only one, either 
under /etc/httpd/logs OR under /var/log/httpd. Make sure you are 
looking at the correct one before you inspect it with the tail command.

VERY IMPT. Please run perl with the -w switch like so

#!/usr/bin/perl -w

This will print out a whole slew of warnings that will help you get to 
the bottom of your problem.

Thanks,

pk/


>
>
> ---------- Original Message ----------------------------------
> From: Puneet Kishor <pkishor at geoanalytics.com>
> Date:  Sat, 9 Nov 2002 19:36:00 -0600
>
>>
>> On Saturday, November 9, 2002, at 11:09  AM, krung wrote:
>>
>>> Hi Lowell, Puneet
>>>
>>> I tried as you told me. If I ran with command line, mapserver.log was
>>> created whem error occured. But when run on Apache, mapserver's never
>>> created as error occured. (access right with this directory'd set to
>>> 777 already) So I checked it at error_log of httpd log file, but it's
>>> non-sense to me. It showed only "Premature of script headers:
>>> /usr/mapserver/testmap.pl".
>>>
>>> And I tried to change script logic flow as you, Puneet, told me. It's
>>> the same error as before (Internal Server Error).
>>
>> Krung,
>>
>> You really have to tell us what the error is. The "Internal Server
>> Error" is the end result. Usually, that end result is the result of 
>> one
>> or more errors happening in tandem. Do the following (assuming your
>> apache log is under /var/log/httpd/)... type "tail -f
>> /var/log/httpd/error_log". This will output the last few lines of the
>> log file on your stdout, and keep the handle open. Now run your
>> mapserver script via the web server. You will see the tail output
>> change. Copy the lines that were outputted as a result of your last
>> attempt to load the mapserver page. Mail that to the list. Then we 
>> will
>> know better what is going on.
>>
>> Another question. In your message you say
>>
>>>>> $img = $map->draw();  # <---- error took place here
>>
>>
>> How do you know that the error took place there? Usually the script
>> breaks because of an error before the break.
>>
>> Again, send us all the error messages. Only then can we help.
>>
>> I am assuming that perl runs fine as cgi on your computer otherwise.
>>
>> pk/
>>
>>
>>
>>
>>>
>>> Do I have to specially configure when I create mapserver program? Any
>>> comments, help, advice would be graceful.
>>>
>>> Thank you
>>> Krung
>>>
>>>
>>> ---------- Original Message ----------------------------------
>>> From: "Lowell Filak"<lfilak at medinaco.org>
>>> Date:  Thu, 07 Nov 2002 08:24:06 -0500
>>>
>>>> You can try adding the line noted below and see if a file
>>>> mapserver.log exists in the current directory and if it reports an
>>>> error.
>>>> If the mapserver.log file isn't created then try changing the path 
>>>> of
>>>> the log file to somewhere writeable by the apache process.
>>>> HTH
>>>> Lowell F.
>>>>
>>>> The following message was sent by "Krung Saengpole" 
>>>> <krung at cad.go.th>
>>>> on Thu,  7 Nov 2002 18:45:20 +0700.
>>>>
>>>>> Hello all,
>>>>>
>>>>> I had trouble getting perl mapscript run on Apache 1.3.26 under RH
>>>>> 7.2. Mapscript compiled from mapserver 3.6.3.
>>>>>
>>>>> My script is:
>>>>>
>>>>> #!/usr/bin/perl
>>>>> use mapscript;
>>>>> use CGI qw/:standard/;
>>>>
>>>> $ENV{MS_ERRORFILE} = "mapserver.log"; <--Try adding this line.
>>>>
>>>>>
>>>>> print header();
>>>>> print start_html();
>>>>> $map = new mapObj('mapfile.map');
>>>>> $img = $map->draw();  # <---- error took place here
>>>>> $img->saveImage('file.png', $mapscript::MS_PNG,1,1,0);
>>>>> ....
>>>>> ....
>>>>>
>>>>> What I did wrong with this script or anything else? But I could run
>>>>> this script at command line. I'm very new to Linux. I tried to 
>>>>> write
>>>>> a script that open database and run under Apache, it had no 
>>>>> problem.
>>>>> So, I thought it should not be wrong with Apache configuration.
>>>>>
>>>>> Thank you in advance.
>>>>> Krung.
>>>>
>>>>
>>>>
>>
>>
>>




More information about the mapserver-users mailing list