6

I installed QGis-Server 2.14 on Ubuntu 16.04 following the instructions on this blog. The fgci on its own is responsive and correctly replying to a GetCapabilities request like:

http://localhost/cgi-bin/qgis_mapserv.fcgi?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities

However, if I point the browser to a QGis project file, like:

http://localhost/cgi-bin/project/qgis_mapserv.fcgi?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities

The response is an error:

<ServiceExceptionReport version="1.3.0">
  <ServiceException code="WMS configuration error">
    There was an error reading the project file or the SLD configuration
  </ServiceException>
</ServiceExceptionReport>

Using directly the command line I get a different error message:

$ ./qgis_mapserv.fcgi "QUERY_STRING=SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities"
QFSFileEngine::open: No file name specified
Warning 1: Unable to find driver ECW to unload from GDAL_SKIP environment variable.
Warning 1: Unable to find driver ECW to unload from GDAL_SKIP environment variable.
Warning 1: Unable to find driver JP2ECW to unload from GDAL_SKIP environment variable.
Warning 1: Unable to find driver ECW to unload from GDAL_SKIP environment variable.
Warning 1: Unable to find driver JP2ECW to unload from GDAL_SKIP environment variable.
Content-Length: 206
Content-Type: text/xml; charset=utf-8

<ServiceExceptionReport version="1.3.0" xmlns="http://www.opengis.net/ogc">
 <ServiceException code="Service configuration error">Service unknown or unsupported</ServiceException>
</ServiceExceptionReport>

The Apache logs are clean. The error log is empty and the access log is reporting nothing unusual.

Are there any other logs I can look into? Any hints on what may be causing this error(s)?

Update I: I was able to set up logging following the suggestions by elpaso66. As he expected, QGis-Server is returning a file not found error, but the file actually exists:

$ tail /tmp/qgis-000.log
[8066][15:50:44] inserting pair MAP // /usr/lib/cgi-bin/project/project.qgs into the parameter map
[8066][15:50:44] MAP:/usr/lib/cgi-bin/project/project.qgs
[8066][15:50:44] REQUEST:GetCapabilities
[8066][15:50:44] SERVICE:WMS
[8066][15:50:44] VERSION:1.3.0
[8066][15:50:44] Error, configuration file '/usr/lib/cgi-bin/project/project.qgs' does not exist
[8066][15:50:44] Checking byte array is ok to set...
[8066][15:50:44] Byte array looks good, setting response...
[8066][15:50:44] Sending HTTP response
[8066][15:50:44] Request finished in 0 ms

$ ls -la /usr/lib/cgi-bin/project/project.qgs
lrwxrwxrwx 1 root root 49 Sep 29 14:41 /usr/lib/cgi-bin/project/project.qgs -> /home/desouslu/Projects/project/project.qgs

$ ls -la /home/desouslu/Projects/project/project.qgs
-rw-rw-r-- 1 desouslu desouslu 156185 Aug 16 15:40 /home/desouslu/Projects/project/project.qgs

Update II: This ended up being an issue with permissions. On Ubuntu, folders created in the home folder by default do not have execution permissions for all. A chmod a+x is required on the folder structure leading to the .qgs file, otherwise Apache fails to access it.

  • Thanks for the hint with execution permissions for qgis file, additionally I had to add read permissions for all. So the file ended up having 775 permissions. – geraldo Jul 27 '17 at 11:45
7

While you can configure the server to automatically serve a particular project, it's normally easier to specify the project (full) path directly with the MAP parameter in the query string, like:

http://localhost/cgi-bin/project/qgis_mapserv.fcgi?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities&MAP=/path/to/your/project.qgs

To get some useful logs out of QGIS, you might want to follow the tips given in this page: http://www.itopen.it/qgis-server-python-plugins-ubuntu-setup/lang-pref/en/

In particular see:

FcgidInitialEnv QGIS_DEBUG 1
FcgidInitialEnv QGIS_SERVER_LOG_FILE /tmp/qgis-000.log
FcgidInitialEnv QGIS_SERVER_LOG_LEVEL 0

The different error messages... the first error There was an error reading the project... usually means that the project file was not found, the second message Service configuration error is caused by the way you pass the env vars, which is wrong and hence no env vars are actually passed to the script and SERVICE has no value inside the script:

/qgis_mapserv.fcgi "QUERY_STRING=SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities"

Should be:

QUERY_STRING="SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities" /qgis_mapserv.fcgi 

or with an export ...

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.