=========================
Installing the AEN server
=========================

.. contents::
   :local:
   :depth: 1

The AEN server is the administrative front end to the system.
This is where users log in to the system, where user accounts are
stored, and where admins can manage the system.

Server is installed in the ``/opt/wakari/wakari-server``
directory.


Installing the bzip2 package
============================

Be sure you have the `bzip2` package installed. If this package
is not installed on your system, install it:

.. code-block:: bash

   sudo yum install bzip2


Downloading prerequisite RPMs
=============================

.. * Air Gap Installation: Copy RPMs from the Air Gap media.

.. * Regular Installation:

To install AEN on a CentOS 6 server:

.. code-block:: bash

   RPM_CDN="https://820451f3d8380952ce65-4cc6343b423784e82fd202bb87cf87cf.ssl.cf1.rackcdn.com"
   curl -O $RPM_CDN/nginx-1.6.2-1.el6.ngx.x86_64.rpm
   curl -O $RPM_CDN/mongodb-org-tools-2.6.8-1.x86_64.rpm
   curl -O $RPM_CDN/mongodb-org-shell-2.6.8-1.x86_64.rpm
   curl -O $RPM_CDN/mongodb-org-server-2.6.8-1.x86_64.rpm
   curl -O $RPM_CDN/mongodb-org-mongos-2.6.8-1.x86_64.rpm
   curl -O $RPM_CDN/mongodb-org-2.6.8-1.x86_64.rpm
   curl -O $RPM_CDN/elasticsearch-1.7.2.noarch.rpm
   curl -O $RPM_CDN/jre-8u65-linux-x64.rpm

To install AEN on a CentOS 7 server:

.. code-block:: bash

   RPM_CDN="https://820451f3d8380952ce65-4cc6343b423784e82fd202bb87cf87cf.ssl.cf1.rackcdn.com"
   curl -O $RPM_CDN/nginx-1.10.2-1.el7.ngx.x86_64.rpm
   curl -O $RPM_CDN/mongodb-org-tools-2.6.12-1.x86_64.rpm
   curl -O $RPM_CDN/mongodb-org-shell-2.6.12-1.x86_64.rpm
   curl -O $RPM_CDN/mongodb-org-server-2.6.12-1.x86_64.rpm
   curl -O $RPM_CDN/mongodb-org-mongos-2.6.12-1.x86_64.rpm
   curl -O $RPM_CDN/mongodb-org-2.6.12-1.x86_64.rpm
   curl -O $RPM_CDN/jre-8u112-linux-x64.rpm
   curl -O $RPM_CDN/elasticsearch-1.7.6.noarch.rpm


Installing prerequisite RPMs
============================

Run:

.. code-block:: bash

   sudo yum install -y *.rpm
   sudo service mongod start
   sudo chkconfig --add elasticsearch


Setting variables and changing permissions
==========================================

Run:

.. code-block:: bash

   export AEN_SERVER=<FQDN HOSTNAME OR IP ADDRESS> # Use the real FQDN
   chmod a+x aen-*.sh                # Set installer to be executable

NOTE: Change <FQDN HOSTNAME OR IP ADDRESS> to the actual fully qualified domain
hostname or IP address.

Running the AEN server installer
================================

Run:

.. code-block:: bash

   sudo -E ./aen-server-4.2.2-Linux-x86_64.sh -w $AEN_SERVER
   <license text>
   ...
   ...

   PREFIX=/opt/wakari/wakari-server
   Logging to /tmp/wakari_server.log
   Checking server name
   Ready for pre-install steps
   Installing miniconda
   ...
   ...
   Checking server name
   Loading config from /opt/wakari/wakari-server/etc/wakari/config.json
   Loading config from /opt/wakari/wakari-server/etc/wakari/wk-server-config.json


   ===================================

   Created password '<RANDOM_PASSWORD>' for user 'aen_admin'

   ===================================


   Starting Wakari daemons...
   installation finished.

After successfully completing the installation script, the installer creates
the administrator account---AEN_SRVC_ACCT user---and assigns it a password.

EXAMPLE:

.. code-block:: bash

   Created password '<RANDOM_PASSWORD>' for user 'aen_admin'

TIP: Record this password. It will be needed in the following steps. It is also
available in the installation log file ``/tmp/wakari_server.log``.


Starting NGINX and Elasticsearch
================================

When SELinux is enabled, it blocks NGINX from connecting to the socket created by
Gunicorn. If you have SELinux enabled, run these commands to correct these permissions
and allow connections between NGINX and Gunicorn::

    sudo semanage fcontext -a -t httpd_var_run_t "/opt/wakari/wakari-server/var/run/wakari-server.sock"
    sudo restorecon -r /opt/wakari/wakari-server/var/run

To start NGINX and Elasticsearch to read the new config file:

.. code-block:: bash

    sudo service nginx start
    sudo service elasticsearch start

TIP: If the AEN web page shows an NGINX 404 error, restart NGINX:

.. code-block:: bash

    sudo nginx -s stop
    sudo nginx

Testing AEN server installation
===============================

Visit http://$AEN_SERVER.

The License expired page is displayed.

.. figure:: /img/aen-install-server-nolicensefound.png
   :width: 50%

|


Updating your license
=====================

From the License expired page, follow the onscreen instructions to upload your
license file.

After your license is submitted, you will see this page:

.. figure:: /img/aen-install-server-login.png
   :width: 50%

|

What's next
===========

:doc:`Install the AEN gateway <install-gateway-node>`.
