I'm executing Mapserver 5.6.4 under Apache2 in a Ubuntu 10.04 machine. I'm having problems writing log file. In the mapfile, I have:

CONFIG  "MS_ERRORFILE" "/var/www/mapserver/log/mylogfile.log"

Any request I make gets the same answer

msSetErrorFile(): General error message. Failed to open MS_ERRORFILE /var/www/mapserver/log/mylogfile.log

If I change the path to /tmp/mylogfile.log it works, but then I have a similar problem with SLD:

msHTTPExecuteRequests(): HTTP request error. HTTP: request failed with curl error code 7 (Failed connect to mymachine:80; Operation now in progress) for http://mymachine/sld/polygon_simplepolygon.sld msSLDApplySLDURL: WMS server error. Could not open SLD http://mymachine/sld/polygon_simplepolygon.sld and save it in temporary file /var/www/mapfiles/4df0f886_22dd_0.sld.xml. Please make sure that the sld url is valid and that imagepath and imageurl are set properly in the map file

IMAGEPATH and IMAGEURL are properly set in Mapfile (a writable directory and a correct url). The log directory belongs to www-data, and the SLD directory too, and www-data has write permission in both directories. I made a test executing, with the www-data user, a python script that creates a file in those directories and it works.

Why mapserv process can't do it? Even when I change the permissions of log directory or SLD directory to 777, mapserv can't write on them, but it can it /tmp. Why?

Many thanks in advance, and best regards,


It is a bad idea to write data to /var/www ; Check whether apparmor for apache is enabled, it may disable writing to that directory (but it is better to use a different one anyway, and chown it 1777).

sudo aa-status

(to check whether apparmor is enabled for apache)

  • Thanks for your response! Yes, apparmor is enabled, and I can't disable it :-(. I changed the log path and now that part is working, but the SLD parameter still fails with a ServiceException: – Jorge Arévalo Jun 14 '11 at 15:07

Just change the permission (777 is sufficient) to your logfile. In your case:

chmod 777 /var/www/mapserver/log/mylogfile.log

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.