Qgis-server...Installation on Ubuntu 16.04 LTS
July 22, 2016
http://www.paulshapley.com/2016/07/how-to-install-qgis-server-on-ubuntu.html
**** dont do this if its a clean server intallation ******************************
Before we start it is always a good idea to remove and re-install apache2 web server so that we start from the same set up:-
To remove Apache2:-
$ sudo apt --purge remove apache2
$ sudo apt autoremove
To re-install Apache2:-
$ sudo apt install apache2
$ sudo /etc/init.d/apache2 restart
# or
$ sudo service apache2 restart
*********************************************************************************
1. $ sudo apt install apache2 (if not installed already done so as above)
2. $ sudo apt install qgis-server libapache2-mod-fcgid
3. $ sudo a2enmod fcgid
4. $ sudo a2enconf serve-cgi-bin
5. $ sudo service apache2 restart
6. add the following code and don't forget to save the changes:-
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<directory "="" usr="" lib="" cgi-bin="">
Options ExecCGI FollowSymLinks
Require all granted
AddHandler fcgid-script .fcgi
< /Directory >
into /etc/apache2/sites-available/000-default.conf
$ sudo gedit /etc/apache2/sites-available/000-default.conf
# so that it looks like this:-
< VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
< Directory "/usr/lib/cgi-bin/">
Options ExecCGI FollowSymLinks
Require all granted
AddHandler fcgid-script .fcgi
< /Directory>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
< / VirtualHost >
7. $ sudo service apache2 restart
8. Test the 'GetCapabilities' request by clicking on the following url:-
localhost or ip address
http://localhost/cgi-bin/qgis_mapserv.fcgi?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities