Skip to content

Instantly share code, notes, and snippets.

@d3netxer
Last active January 9, 2018 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save d3netxer/5de5e88641c083aec6ed1524da001bd2 to your computer and use it in GitHub Desktop.
Save d3netxer/5de5e88641c083aec6ed1524da001bd2 to your computer and use it in GitHub Desktop.

Installing QGIS Server on Ubuntu 16.04

sudo apt-get update

edited the /etc/apt/sources.list file and added:

deb https://qgis.org/debian xenial main deb-src https://qgis.org/debian xenial main

(I don't think this step is needed: sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable)

(from https://chrisjean.com/fix-apt-get-update-the-following-signatures-couldnt-be-verified-because-the-public-key-is-not-available/)

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys CAEB3DC3BDF7FB45

sudo apt-get update

sudo apt-get install qgis-server python-qgis

followed this doc (https://docs.qgis.org/2.18/en/docs/training_manual/qgis_server/install.html) starting at section 12.1.3:

...starting with installing Apache by running the following command in a terminal: sudo apt-get install apache2 libapache2-mod-fcgid

Create this directory: /home/ubuntu/qgis/projects

The directory above is where the QGIS projects will go. Each QGIS project file (.qgs) will have its own folder along with the data. The .qgs will use relative links for the data.

In the /etc/apache2/sites-available directory create a file called qgis.demo.conf

add the same text as in the guide except for a few changes:

  • for ServerName put in the IP address of your server
  • comment out the QGIS_PROJECT_FILE line (to not have a default QGIS project)
  • make sure the paths are correct for the QGIS_AUTH_DB_DIR_PATH, QGIS_AUTH_PASSWORD_FILE, PGSERVICEFILE, and PGPASSFILE. I had to correct my home directory path by inserting ubuntu in the link.

Make sure you add your IPaddress qgis.demo entry in the hosts file.

Restart the server sudo service apache2 restart

when you are done you can test by going somewhere like this: insert_ip_address/cgi-bin/qgis_mapserv.fcgi?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities

You can then get individual projects, and connect to them by adding a WMS service in QGIS desktop by adding &map= requests for Ex.

http://34.224.18.247/cgi-bin/qgis_mapserv.fcgi?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities&map=/home/ubuntu/qgis/projects/world.qgs

http://34.224.18.247/cgi-bin/qgis_mapserv.fcgi?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities&map=/home/ubuntu/qgis/projects/test1/test1.qgs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment