QGIS Server on Ubuntu – How to Resolve Permission Denied Errors

qgisqgis-serverUbuntu

I'm trying to install and configure QGIS Server (2.0.1) on a virtual server with Ubuntu 14.04, Apache 2.4.7.

After trying to install normally, the server gave me 404 error, so I tried to add configuration to /etc/apache2/sites-available/000-default.conf following different code snippets, but each try result in a 403 error (permission denied), testing for example an URL like "/cgi-bin/qgis_mapserv.fcgi?SERVICE=WMS&REQUEST=GetCapabilities"

What are the correct steps to configure QGIS?

Best Answer

Here my usual steps to configure wms di qgis (2.4) tested on ubuntu 12.04 and 14.04

1) Install some requested packages:

sudo apt-get install qgis-mapserver libapache2-mod-fcgid

2) Be sure fastcgi is enabled in apache2 modules:

ls -la /etc/apache2/mods-enabled/fcgid.conf

2a) Modify /etc/apache2/sites-available/000-default.conf and add inside VirtualHost: ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin/"> Options ExecCGI FollowSymLinks Require all granted AddHandler fcgid-script .fcgi </Directory>

3) Restart apache2 http server

sudo service apache2 restart

4) Try to access to service using a browser type:

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

5) Try a qgis project in your user dirs:

/home/ubuntu/my_qgis_project_dir/my_qgis_project.qgs

Still using a browser verify the web address (note the MAP has an absolute path to the project, otherwise you'll get a 500 error):

http://127.0.0.1/cgi-bin/qgis_mapserv.fcgi?SERVICE=WMS&MAP=/home/ubuntu/my_qgis_project_dir/my_qgis_project.qgs&REQUEST=GetCapabilities  

6) Use qgis (or also other client software) add the WMS service

Qgis menu: Layer → Add layer WMS/WMTS layer

simply add the http addr above... connect to service and add desired layers


If you get 403 errors please verify your dir $HOME permissions mine are drwxr-xr-x and also some apache2 conf:

http://www.cyberciti.biz/faq/apache-403-forbidden-error-and-solution/