Q:

How to install PyWPS on Ubuntu?

Since PyWPS is not yet packaged for Ubuntu an installation guide would be handy. This guide should target a vanilla Ubuntu LTS install, detailing the required dependencies.

A:

This guide was successfully tested with PyWPS 3.2 on Ubuntu 10.04, 12.04 and 14.04. Throughout the guide pico is used to edit files, but you can use your text editor of choice instead.
1. Installation
Install dependencies, clone the project from GitHub and install it:
sudo apt-get install apache2 python-setuptools python-magic python-lxml  git-core wget

git clone https://github.com/geopython/PyWPS.git

cd ./PyWPS

sudo python setup.py install

2. Create folders for PyWPS assets
For convenience, in this example all PyWPS assets are stored in /var/www, a typical setup for a development environment. In a server setup it might be wiser to store processes in /srv and logs in /var/log.
sudo mkdir /var/www/pywps

sudo mkdir /var/www/wpsoutputs

sudo cp -R pywps/processes /var/www/pywps

Create log and configuration files:
sudo touch /var/www/pywps/pywps.log

sudo cp pywps/default.cfg /var/www/pywps/pywps.cfg

sudo pico /var/www/pywps/pywps.cfg

In the configuration file only the Server environment needs to be tweaked, in order to match the asset locations created before. The set up of the GRASS and MapServer environments are left for a later date. 

    [server] 
    maxoperations=30
    maxinputparamlength=1024 
    maxfilesize=500mb
    tempPath=/tmp
    processesPath=/var/www/pywps/processes
    outputUrl=http://localhost/wpsoutputs
    outputPath=/var/www/wpsoutputs 
    debug=true # deprecated since 3.2, use logLevel instead
    logFile=/var/www/pywps/pywps.log

Pass ownership to the www-data user (again, in a server setup you might want to be more conservative):
sudo chown -R www-data:www-data /var/www/pywps /var/www/wpsoutputs

3. Configure the web service
Copy the PyWPS CGI to /usr/lib/cgi-bin:
sudo cp webservices/cgi/pywps.cgi /usr/lib/cgi-bin

whereis wps.py

Copy the path of wps.py to the clipboard.
sudo pico /usr/lib/cgi-bin/pywps.cgi

Modify pywps.cgi to match the present setup:

    export PYWPS_CFG=/var/www/pywps/pywps.cfg 
    export PYWPS_PROCESSES=/var/www/pywps/processes/

    /usr/local/bin/wps.py $1

Give it a try:
cd /usr/lib/cgi-bin

sudo sh pywps.cgi "request=GetCapabilities&service=WPS"

Make sure Apache is configured to run CGI scripts; the CGI module might need to be explicitly enabled:
sudo a2enmod cgid

Edit the default site configuration (Ubuntu 10.04 and 12.04):
sudo pico /etc/apache2/sites-available/default

In Ubuntu 14.04:
sudo pico /etc/apache2/sites-available/000-default.conf

Verify that this section is included, add the necessary keywords to make it look like this (in Ubuntu 12.04 this may already be the default configuration):

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>

Restart Apache:
sudo /etc/init.d/apache2 restart

4. Testing
From the command line:
wget -O response.xml -v "http://localhost/cgi-bin/pywps.cgi?REQUEST=GetCapabilities&SERVICE=WPS"

wget -O response.xml -v "http://localhost/cgi-bin/pywps.cgi?REQUEST=Execute&IDENTIFIER=dummyprocess&SERVICE=WPS&VERSION=1.0.0&DATAINPUTS=Input1=1;Input2=1"

The same URLs can be used in a browser like Firefox.

