==================
Install AEN Server
==================

The AEN Server is the administrative front-end to the Anaconda Enterprise Notebooks. 
This is where users login to the system, where user accounts are stored, and
where admins can manage the system.

These procedures assume you have already met all installation requirements 
in :doc:`install-prep`. 

AEN Server preparation prerequisites
======================================

Install bzip2 package
---------------------

Make sure you have the ``bzip2`` package installed. If not, you can install it with::

        sudo yum install bzip2

Download prerequisite RPMs
--------------------------

Which Red Hat Package Management (RPM) installer files you will need depends on 
which version of CentOS or Red Hat you're using. 

To install AEN on a **CentOS/Red Hat 6** server::

       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/Red Hat 7** server::

        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/elasticsearch-1.7.6.noarch.rpm
        curl -O $RPM_CDN/jre-8u112-linux-x64.rpm

Install prerequisite RPMs
-------------------------

::

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

Run the AEN Server installer
============================

Set variables and change permissions
------------------------------------

::

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

Run AEN Server installer
------------------------

::

        sudo -E ./aen-server-4.1.3-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.


As part of the installation script, the installer creates the 
administrator account (``AEN_SRVC_ACCT`` user, also known as user ``wakari``) 
and assigns it a password. **Record this password** to use in the following steps. 
It is also available in the installation log file found at
``/tmp/wakari_server.log``. This password can be changed in the 
admin interface. 

Start NGINX and ElasticSearch
-----------------------------

When SELinux is enabled, ``httpd_can_network_connect`` is disabled by default,
which prevents NGINX from connecting to Gunicorn. If you have SELinux enabled,
run this command to correct these permissions and allow connections between
NGINX and Gunicorn::

    sudo setsebool httpd_can_network_connect 1 -P

Start ``NGINX`` and ElasticSearch to read the new config files::

    sudo service nginx start
    sudo service elasticsearch start

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

    sudo nginx -s stop
    sudo nginx
    
Test the AEN Server install
---------------------------

Visit http://$AEN_SERVER. You should be shown the **"No license found"** page.

.. image:: /img/aen-install-server-nolicensefound.png

Update the license
------------------

From the **"No license found"** page, follow the onscreen instructions to
upload your license file. After submitting it, you should see the login
page.

Next steps
==========

See the next steps needed for full AEN install below:

#. :doc:`install-gateway`
#. :doc:`install-compute` 
   
The following optional install procedures may need to be performed, 
depending on how you set up your Data Center:
   
* :doc:`option-config`
* :doc:`customization`
* :doc:`ldap`
* :doc:`ssl`
* :doc:`sso`
   
Additional post-install information:
   
* :doc:`installation_update`
* :doc:`uninstall`
* :doc:`release`
