Installation
==================================

PiAnoS is not a regular desktop application that you can install using common techniques (Wizard-based installer on Windows, or using a package manager such as ``apt-get`` on Linux). In fact, what you are installing is the `server` part of PiAnoS - the client being merely a web browser. This is a multiple-step process that may look scary at first. Don't worry because in the end 1) it `will` work and 2) you will have learnt a lot. 

In this chapter, we assume that PiAnoS is the only application running on the server. For most people (including IT folks) using a dedicated server, this will be the case. Those of you already using Apache and/or PostgreSQL, should be able to adapt the procedures described here to their specific configuration.

Since the server-side installation can (and should) be done on a unix-based system, a (linux) Docker version is available on the git repo for ease of installation.

.. note:: PiAnoS does not `require` a dedicated server and hapilly sits with other applications running on the same web server and database server. But writing detailed procedures assuming fresh systems is easier for me, and is a common scenario for starters who are the main audience of this chapter.

After installing PiAnoS, the command ``make prod`` can be executed from the root of PiAnoS, to remove some logging function (see the "Makefile" file for more informations). The "install" directory shoud be restricted or remove.

Super-quick installation
------------------------

PiAnoS can be deployed as a Docker image. The following steps are needed:

    - install git
    - install docker (|dockergetlink|)
    - install docker-compose (|dockercomposelink|)
    - Run:

.. code-block:: bash

    $ git clone --recursive https://esc-md-git.unil.ch/PiAnoS/docker.git .
    $ docker-compose up --build -d

This command need to be executed from within the PiAnoS directory (created by the user; will store the database and all importants files for PiAnoS).

.. note::
    This git repo is stil in developement. The Dockerfile will be improved very soon.

.. |dockergetlink| raw:: html

	<a href="https://get.docker.com/" target="_blank">here</a>

.. |dockercomposelink| raw:: html
	
	<a href="https://docs.docker.com/compose/install/#install-compose" target="_blank">here</a>

.. note::
    
    See the detailed installation page for Docker here: :doc:`docker`.

Quick install
-----------------------------------

This quick installation procedure is aimed at people who are familiar with the deployment of web applications. New users should follow the "long" install procedure, which details all steps.

	- Get Apache + PHP + PostgreSQL (see the :doc:`requirements` for recommended versions)
	- Unpack PiAnoS like any other web app (e.g. in ``/var/www``, use symlinks, etc.)
	- Create a PostgreSQL database (use UTF-8 encoding)
	- Run the web installer to configure PiAnoS (alter ``$(TOP)/backend/settings-local.php`` afterwards if needed)
	- Remove the ``$(TOP)/install`` directory

Long install
-----------------------------------

Depending on your operating system, the procedure can be quite different. I have included step-by-step explanations for two major OSes: Debian GNU/Linux and Windows 7. If you use another Linux OS, you should use the Debian guide and adapt it to your system (users of Ubuntu will have almost nothing to change). No guide exists for OSX systems.

.. toctree::
	:maxdepth: 1

	requirements
	docker
	debian
	win7
	webinstall
	troubleshooting

