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)
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