OMERO.server Linux walkthrough
==============================

This is an example walkthrough for installing OMERO on Linux with Nginx, using
a dedicated system user, and should be read in conjunction with
:doc:`server-installation`. You can use this as a guide for setting up your
own test server. For production use you should also read the pages listed
under :ref:`index-optimizing-server`.

Example shell scripts for installing OMERO on Ubuntu 14.04 are included
in-line, and can be downloaded. Separate instructions for installing on
CentOS 6 are also available where this differs from the Ubuntu instructions.
These instructions assume your Linux distribution is configured with a UTF-8
locale (this is normally the default).

For convenience in this walkthrough the main OMERO configuration options have
been defined as environment variables. When following this walkthrough you can
either use your own values, or alternatively source the following file:

.. literalinclude:: walkthrough/settings.env

:download:`settings.env <walkthrough/settings.env>`


Prerequisites
-------------

As **root** install Ice, Java, Postgres:

.. literalinclude:: walkthrough/dependencies-ubuntu1404.sh

| :download:`dependencies-ubuntu1404.sh <walkthrough/dependencies-ubuntu1404.sh>`
| :download:`dependencies-centos6.sh <walkthrough/dependencies-centos6.sh>`

Create an omero system user, and a directory for the OMERO repository:

.. literalinclude:: walkthrough/system_setup.sh

:download:`system_setup.sh <walkthrough/system_setup.sh>`


Create a database user and initialize a new database for OMERO:

.. literalinclude:: walkthrough/setup_postgres.sh

:download:`setup_postgres.sh <walkthrough/setup_postgres.sh>`


Installing OMERO.server
-----------------------

As the **omero** system user download, unzip and configure OMERO, and create a
configuration file for Nginx. The rest of this walkthrough assumes the
OMERO.server is installed into the home directory of this user.

Note that this script requires the same environment variables that were set
earlier in `settings.env`, so you may need to copy and/or source this file as
the omero user.

.. literalinclude:: walkthrough/setup_omero_ice35.sh

:download:`setup_omero_ice35.sh <walkthrough/setup_omero_ice35.sh>`


Installing Nginx
----------------

As **root** install Nginx, copy the Nginx OMERO configuration file into the
Nginx configuration directory, and disable the default configuration:

.. literalinclude:: walkthrough/setup_nginx_ubuntu1404.sh

| :download:`setup_nginx_ubuntu1404.sh <walkthrough/setup_nginx_ubuntu1404.sh>`
| :download:`setup_nginx_centos6.sh <walkthrough/setup_nginx_centos6.sh>`


Running OMERO
-------------

OMERO should now be set up. To start the server log in as the **omero** system
user, and run::

    OMERO.server/bin/omero admin start

To start the OMERO.web client run::

    OMERO.server/bin/omero web start

Nginx should already be running, so you should be able to log in as the OMERO
root user by going to http://localhost/ in your web browser.

In addition some example `init.d` scripts are available should you wish to
start OMERO and OMERO.web automatically:

.. literalinclude:: walkthrough/setup_omero_daemon_ubuntu1404.sh

| :download:`setup_omero_daemon_ubuntu1404.sh
  <walkthrough/setup_omero_daemon_ubuntu1404.sh>`
| :download:`setup_omero_daemon_centos6.sh
  <walkthrough/setup_omero_daemon_centos6.sh>`
| :download:`omero-init.d <walkthrough/omero-init.d>`
| :download:`omero-web-init.d <walkthrough/omero-web-init.d>`


SELinux
-------

If you are running a system with SELinux enabled (for example, it is
`enabled by default on CentOS6 <http://wiki.centos.org/HowTos/SELinux>`_)
and are unable to access OMERO.web via Nginx you may need to adjust the
security policy:

.. literalinclude:: walkthrough/setup_nginx_centos6_selinux.sh

| :download:`setup_nginx_centos6_selinux.sh <walkthrough/setup_nginx_centos6_selinux.sh>`