how to install dbnp/gscf with java 8, tomcat 8, apache ... · most of the commands in this tutorial...

24
Tutorial: Install dbNP on CentOS/RHEL 7 (v3) 1/24 PhenotypeDatabase / GSCF Finn Sandø Department of Nutrition, Exercise and Sports (NEXS) University of Copenhagen How to install dbNP/GSCF with java 8, tomcat 8, Apache, PostgreSQL 9.5 On CentOS 7 / RHEL 7 This tutorial builds heavily on the instructions that can be found on the PhenotypeDatabase github page https://github.com/PhenotypeFoundation/PhenotypeDatabase#installation Finn Sandø Department of Nutrition, Exercise and Sports (NEXS) University of Copenhagen

Upload: others

Post on 10-Mar-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: How to install dbNP/GSCF with java 8, tomcat 8, Apache ... · Most of the commands in this tutorial need to be executed as ”root”, so the easiest is to just ”become root”

Tutorial: Install dbNP on CentOS/RHEL 7 (v3) 1/24 PhenotypeDatabase / GSCF

Finn Sandø – Department of Nutrition, Exercise and Sports (NEXS) – University of Copenhagen

How to install dbNP/GSCF with java 8, tomcat 8, Apache, PostgreSQL 9.5 On

CentOS 7 / RHEL 7

This tutorial builds heavily on the instructions that can be found on the PhenotypeDatabase github page

https://github.com/PhenotypeFoundation/PhenotypeDatabase#installation

Finn Sandø Department of Nutrition, Exercise and Sports (NEXS)

University of Copenhagen

Page 2: How to install dbNP/GSCF with java 8, tomcat 8, Apache ... · Most of the commands in this tutorial need to be executed as ”root”, so the easiest is to just ”become root”

Tutorial: Install dbNP on CentOS/RHEL 7 (v3) 2/24 PhenotypeDatabase / GSCF

Finn Sandø – Department of Nutrition, Exercise and Sports (NEXS) – University of Copenhagen

Introduction

In this tutorial it is assumed that you are logged in to a freshly installed CentOS 7 or RHEL 7 server (Redhat Enterprise Linux - RHEL).

l will go through installing and configuring:

Java 8 – I will show how to install java both from the distribution repository and directly from Oracle

Tomcat 8 – java application server

Apache – web server (will act as web facing front end)

mod_jk – a necessary component for Apache not natively supported by Redhat that needs to be compiled

PostgreSQL 9.5 – The latest version of postgres

Virtual hosts – the dbNP website (mostly copy-paste from the PhenotypeDatabase github page)

dbNP/GSCF – the main java application itself

Page 3: How to install dbNP/GSCF with java 8, tomcat 8, Apache ... · Most of the commands in this tutorial need to be executed as ”root”, so the easiest is to just ”become root”

Tutorial: Install dbNP on CentOS/RHEL 7 (v3) 3/24 PhenotypeDatabase / GSCF

Finn Sandø – Department of Nutrition, Exercise and Sports (NEXS) – University of Copenhagen

Installing a few utilities First a few utilities are needed. In order to download files I will use the program ”wget” and in order to edit text files I will use the text editor ”nano”. Most of the commands in this tutorial need to be executed as ”root”, so the easiest is to just ”become root” by this:

sudo su

To install progams in CentOS/Redhat you use the package manager ”yum” Type this to install ”wget” and ”nano”

yum install wget nano

When using the nano editor use ctrl+o to save and ctrl+x to leave

Page 4: How to install dbNP/GSCF with java 8, tomcat 8, Apache ... · Most of the commands in this tutorial need to be executed as ”root”, so the easiest is to just ”become root”

Tutorial: Install dbNP on CentOS/RHEL 7 (v3) 4/24 PhenotypeDatabase / GSCF

Finn Sandø – Department of Nutrition, Exercise and Sports (NEXS) – University of Copenhagen

Installing java 8 – from repository To install from the repository is simple

yum install java-1.8.0-openjdk yum install java-1.8.0-openjdk-devel

To check the installation

java -version whereis java which java

Installing java 8 – from Oracle It may sometimes be needed to use one of the versions provided directly from Oracle First go to Oracle’s website to find the latest version of java http://www.oracle.com/technetwork/java/javase/downloads

Page 5: How to install dbNP/GSCF with java 8, tomcat 8, Apache ... · Most of the commands in this tutorial need to be executed as ”root”, so the easiest is to just ”become root”

Tutorial: Install dbNP on CentOS/RHEL 7 (v3) 5/24 PhenotypeDatabase / GSCF

Finn Sandø – Department of Nutrition, Exercise and Sports (NEXS) – University of Copenhagen

Scroll down, find and click the ”jre” button

Accept the licence agreement

Page 6: How to install dbNP/GSCF with java 8, tomcat 8, Apache ... · Most of the commands in this tutorial need to be executed as ”root”, so the easiest is to just ”become root”

Tutorial: Install dbNP on CentOS/RHEL 7 (v3) 6/24 PhenotypeDatabase / GSCF

Finn Sandø – Department of Nutrition, Exercise and Sports (NEXS) – University of Copenhagen

Find the linux-x86 "rpm" version This is the version for RHEL and CentOS. Note the address, in this case http://download.oracle.com/otn-pub/java/jdk/8u92-b14/jre-8u92-linux-x64.rpm

To download java into the current folder use wget, type (or copy) the following to the command line

wget --no-cookies --no-check-certificate \ --header "Cookie: gpw_e24=http://www.oracle.com/; \ oraclelicense=accept-securebackup-cookie" \ "http://download.oracle.com/otn-pub/java/jdk/8u92-b14/jdk-8u92-linux-x64.rpm"

After the file is successfully downloaded type this to install

rpm -ivh jdk-8u92-linux-x64.rpm

Page 7: How to install dbNP/GSCF with java 8, tomcat 8, Apache ... · Most of the commands in this tutorial need to be executed as ”root”, so the easiest is to just ”become root”

Tutorial: Install dbNP on CentOS/RHEL 7 (v3) 7/24 PhenotypeDatabase / GSCF

Finn Sandø – Department of Nutrition, Exercise and Sports (NEXS) – University of Copenhagen

Installing Tomcat 8 In this part I wil Find and download latest version of Tomcat from the Tomcat site Install Tomcat into the /opt folder Prepare the system for Tomcat Configure Tomcat First, in order to get the lastest version go to the tomcoat.org site http://tomcat.apache.org/download-80.cgi Scroll down to the latest version, not the address in this case http://ftp.download-by.net/apache/tomcat/tomcat-8/v8.0.33/bin/apache-tomcat-8.0.33.tar.gz

To download tomcat files into the current folder

wget http://ftp.download-by.net/apache/tomcat/tomcat-8/v8.0.33/bin/apache-tomcat-8.0.33.tar.gz

Unpack (this will unpack the downloaded file into a folder "apache-tomcat-8.0.33")

tar xzf apache-tomcat-8.0.33.tar.gz

Move the Tomcat files into the /opt folder

mv apache-tomcat-8.0.33 /opt/

Go the /opt folder, in order to standardize access to Tomcat create a symbolic link to the Tomcat folder

cd /opt ln -s apache-tomcat-8.0.33 tomcat

List the content of /opt

ls –l

Page 8: How to install dbNP/GSCF with java 8, tomcat 8, Apache ... · Most of the commands in this tutorial need to be executed as ”root”, so the easiest is to just ”become root”

Tutorial: Install dbNP on CentOS/RHEL 7 (v3) 8/24 PhenotypeDatabase / GSCF

Finn Sandø – Department of Nutrition, Exercise and Sports (NEXS) – University of Copenhagen

drwxr-xr-x. 10 tomcat tomcat 4096 Apr 27 18:30 apache-tomcat-8.0.33 lrwxrwxrwx 1 root root 20 Apr 26 18:39 tomcat -> apache-tomcat-8.0.33

Prepare the system for Tomcat First we need to add a tomcat user and a tomcat group, tell the system that this user’s home dir is /opt/tomcat and, for security reasons, disallow this user login rights. add tomcat user

groupadd tomcat sudo useradd -M -s /bin/nologin -g tomcat -d /opt/tomcat tomcat

Next the permissions on the /opt/tomcat folder need to be set Under normal operation the Tomcat user only needs to be able to change a few config files. Therefore the most secure setup is to make ”root” owner of everything execpt for these few files. Set all files in the /opt folder to be owned by root

cd /opt chown root:root . -R

Allow the tomcat user to change a few config files

cd tomcat chgrp -R tomcat conf chmod g+rwx conf chmod g+r conf/* chown -R tomcat webapps/ work/ temp/ logs/

Sometimes during setup, however, this can be a problem making it necessary to give tomcat full rights

cd /opt chown tomcat:tomcat . -R

Page 9: How to install dbNP/GSCF with java 8, tomcat 8, Apache ... · Most of the commands in this tutorial need to be executed as ”root”, so the easiest is to just ”become root”

Tutorial: Install dbNP on CentOS/RHEL 7 (v3) 9/24 PhenotypeDatabase / GSCF

Finn Sandø – Department of Nutrition, Exercise and Sports (NEXS) – University of Copenhagen

Next we need to create startup scripts so the CentOS/RHEL server can start Tomcat This wil create a systemd unit script to start Tomcat

nano /etc/systemd/system/tomcat.service

The content of the tomcat.service file

# Systemd unit file for tomcat [Unit] Description=Apache Tomcat Web Application Container After=syslog.target network.target [Service] Type=forking Environment=JAVA_HOME=/usr/lib/jvm/jre Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid Environment=CATALINA_HOME=/opt/tomcat Environment=CATALINA_BASE=/opt/tomcat Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC' Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom' ExecStart=/opt/tomcat/bin/startup.sh ExecStop=/bin/kill -15 $MAINPID User=tomcat Group=tomcat [Install] WantedBy=multi-user.target

To start Tomcat, first reload the systemd daemon, start Tomcat (to see that it actually starts). If successful, make the startup happen automatically in the future (enable).

systemctl daemon-reload systemctl start tomcat systemctl enable tomcat

Finally we need to open the firewall for port 80 and port 8080

firewall-cmd --add-port=80/tcp --permanent firewall-cmd --add-port=8080/tcp --permanent firewall-cmd --reload

Tomcat is now installed and running and should be reachable on ”your-domain:8080”

Page 10: How to install dbNP/GSCF with java 8, tomcat 8, Apache ... · Most of the commands in this tutorial need to be executed as ”root”, so the easiest is to just ”become root”

Tutorial: Install dbNP on CentOS/RHEL 7 (v3) 10/24 PhenotypeDatabase / GSCF

Finn Sandø – Department of Nutrition, Exercise and Sports (NEXS) – University of Copenhagen

Configuring Tomcat Next step is to configure tomcat. Tomcat will work fine without further configuration but an administrator may find it useful to have access to Tomcat’s manager interface (”manager-gui” or ”Manager App”). To get access to the Manager App you need to add a user with admin rights to the manager-gui. Edit the ”tomcat-users.xml” file

nano /opt/tomcat/conf/tomcat-users.xml

Create a user with suitable permissions by adding these lines between the

<tomcat-users ...> ... </tomcat-users>

markups. In this case I have created a user ”tomcat” (the name is not important and could be anything)

<role rolename="manager-gui" /> <role rolename="manager-script" /> <role rolename="manager-jmx" /> <role rolename="manager-status" /> <role rolename="admin" /> <user username="tomcat" password="secret" roles="admin,manager-gui,manager-script" />

The complete the ”tomcat-users.xml” file

<?xml version='1.0' encoding='utf-8'?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <tomcat-users xmlns="http://tomcat.apache.org/xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd" version="1.0"> <!-- NOTE: By default, no user is included in the "manager-gui" role required to operate the "/manager/html" web application. If you wish to use this app, you must define such a user - the username and password are arbitrary. It is strongly recommended that you do NOT use one of the users in the commented out section below since they are intended for use with the examples web application. --> <!-- NOTE: The sample user and role entries below are intended for use with the examples web application. They are wrapped in a comment and thus are ignored when reading this file. If you wish to configure these users for use with the examples web application, do not forget to remove the <!.. ..> that surrounds them. You will also need to set the passwords to something appropriate. --> <!-- <role rolename="tomcat"/>

Page 11: How to install dbNP/GSCF with java 8, tomcat 8, Apache ... · Most of the commands in this tutorial need to be executed as ”root”, so the easiest is to just ”become root”

Tutorial: Install dbNP on CentOS/RHEL 7 (v3) 11/24 PhenotypeDatabase / GSCF

Finn Sandø – Department of Nutrition, Exercise and Sports (NEXS) – University of Copenhagen

<role rolename="role1"/> <user username="tomcat" password="tomcat" roles="tomcat"/> <user username="both" password="tomcat" roles="tomcat,role1"/> <user username="role1" password="tomcat" roles="role1"/> --> <role rolename="manager-gui" /> <role rolename="manager-script" /> <role rolename="manager-jmx" /> <role rolename="manager-status" /> <role rolename="admin" /> <user username="tomcat" password="secret" roles="admin,manager-gui,manager-script" /> </tomcat-users>

After the changes have been saved, restart Tomcat

systemctl restart tomcat

It should now be possible to login to the Tomcat Manager App by going to http://mydomain:8080/ Try to click the ”Manager App” button

Page 12: How to install dbNP/GSCF with java 8, tomcat 8, Apache ... · Most of the commands in this tutorial need to be executed as ”root”, so the easiest is to just ”become root”

Tutorial: Install dbNP on CentOS/RHEL 7 (v3) 12/24 PhenotypeDatabase / GSCF

Finn Sandø – Department of Nutrition, Exercise and Sports (NEXS) – University of Copenhagen

Now login with the username and password defined in the ”tomcat-users.xml” file

Page 13: How to install dbNP/GSCF with java 8, tomcat 8, Apache ... · Most of the commands in this tutorial need to be executed as ”root”, so the easiest is to just ”become root”

Tutorial: Install dbNP on CentOS/RHEL 7 (v3) 13/24 PhenotypeDatabase / GSCF

Finn Sandø – Department of Nutrition, Exercise and Sports (NEXS) – University of Copenhagen

increase the allowed size of uploaded files

One last Tomcat configuration that may be needed is to increase the allowed size of uploaded files.

There are several different ways to install a java web application in Tomcat: First there is the completely manual approach that I am going to show in this tutorial, then there is a semi-manual where you place the installation file in the correct place and let Tomcat handle the final steps and finally you can, via the Manager App, upload a web application directly from your desktop to the server.

Unfortunately by default the maximum allowed file size is 50mb but the PhenotypeDatabase is almost 100mb, so when you try to upload it the installation will fail, and the error message may not be obvious.

In order to fix this issue you will have to increase the maximum allowed size of uploaded files. This setting is in the ” manager/WEB-INF/web.xml”

nano /opt/tomcat/webapps/manager/WEB-INF/web.xml

In this file look for this part

... <multipart-config> <!-- 50MB max --> <max-file-size>52428800</max-file-size> <max-request-size>52428800</max-request-size> <file-size-threshold>0</file-size-threshold> </multipart-config> ...

change it to this

... <multipart-config> <!-- 100MB max --> <max-file-size> 104857600</max-file-size> <max-request-size> 104857600</max-request-size> <file-size-threshold>0</file-size-threshold> </multipart-config> ...

After the changes have been applied, restart Tomcat

systemctl restart tomcat

Page 14: How to install dbNP/GSCF with java 8, tomcat 8, Apache ... · Most of the commands in this tutorial need to be executed as ”root”, so the easiest is to just ”become root”

Tutorial: Install dbNP on CentOS/RHEL 7 (v3) 14/24 PhenotypeDatabase / GSCF

Finn Sandø – Department of Nutrition, Exercise and Sports (NEXS) – University of Copenhagen

Installing PostgreSQL 9.5

CentOS 7 / RHEL 7 by default supports postgres 9.2. To get the most recent version you need to use the repositories maintained by the Postgres Organization at http://postgresql.org The process of installing PostgreSQL is to first install the repository and then using the package manager to install postgres Install the repository

rpm -Uvh http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-2.noarch.rpm

Then install PostgreSQL

yum install postgresql95-server postgresql95-contrib

After successful installation the database must be initialized by running this script

/usr/pgsql-9.5/bin/postgresql95-setup initdb

Start postgres and make it start automatically

systemctl start postgresql-9.5 systemctl enable postgresql-9.5

The program to access postgres is ”psql”. In order to be able to access the server you need to make some changes to the postgres user permissions in the ”pg_hba.conf” file.

nano /var/lib/pgsql/9.5/data/pg_hba.conf

In this file change the ”peer” and ”ident” options for the rows ”local” and ”127.0.0.1/32” (those both concern logins that are coming from the server itself) to ”trust” and ”md5” respectively.

... # TYPE DATABASE USER ADDRESS METHOD # "local" is for Unix domain socket connections only local all all trust # peer # IPv4 local connections: host all all 127.0.0.1/32 md5 # ident ...

Save the file and restart postgres

systemctl restart postgresql-9.5

It is now possible to login to postgres with this command (type ”\q” to leave)

psql -U postgres -d postgres

Page 15: How to install dbNP/GSCF with java 8, tomcat 8, Apache ... · Most of the commands in this tutorial need to be executed as ”root”, so the easiest is to just ”become root”

Tutorial: Install dbNP on CentOS/RHEL 7 (v3) 15/24 PhenotypeDatabase / GSCF

Finn Sandø – Department of Nutrition, Exercise and Sports (NEXS) – University of Copenhagen

Creating the database to be used by dbNP/GSCF First login to postgres

psql -U postgres -d postgres

Now create a database user and the database that will be used by the dbNP/GSCF application.

CREATE USER gscfuser WITH PASSWORD 'secret-pw'; CREATE DATABASE gscfwww WITH OWNER gscfuser; GRANT ALL PIVILEGES ON DATABASE gscfwww TO gscfuser;

Please note one important difference compared to the documentation on the PhenotypeDatabase github page: Here I use the database name ”gscfwww” (rather than ”gscf-www” with a dash). The reason is that while this is not important per se, dash in database names is non-standard and will force the use of double quotes in sql-queries every time the database is mentioned, which can be quite inconvenient if direct dealing wth database should be needed.

Page 16: How to install dbNP/GSCF with java 8, tomcat 8, Apache ... · Most of the commands in this tutorial need to be executed as ”root”, so the easiest is to just ”become root”

Tutorial: Install dbNP on CentOS/RHEL 7 (v3) 16/24 PhenotypeDatabase / GSCF

Finn Sandø – Department of Nutrition, Exercise and Sports (NEXS) – University of Copenhagen

Installing Apache web server

Before installing Apache there is a module mod_jk, which helps in conncecting between the Tomcat and Apache, that is not available on CentOS/RHEL. This module needs to compiled specifically.

Download, compile and Install mod_jk

Install the Apache server and the development files necessary for compiling mod_jk

yum install httpd httpd-devel gcc gcc-c++ make libtool

Download and unpack the source code for mod_jk

mkdir mod-jk cd mod-jk wget http://www.eu.apache.org/dist/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.41-src.tar.gz tar -xf tomcat-connectors-1.2.41-src.tar.gz

Compile and install mode_jk

cd tomcat-connectors-1.2.41-src/native ./configure --with-apxs=/usr/bin/apxs make libtool --finish /usr/lib64/httpd/modules make install

Finally we need to install two more moduels for Apache (mod_rewrite and mod_proxy_html)

yum install mod_proxy_html mod_rewrite

Page 17: How to install dbNP/GSCF with java 8, tomcat 8, Apache ... · Most of the commands in this tutorial need to be executed as ”root”, so the easiest is to just ”become root”

Tutorial: Install dbNP on CentOS/RHEL 7 (v3) 17/24 PhenotypeDatabase / GSCF

Finn Sandø – Department of Nutrition, Exercise and Sports (NEXS) – University of Copenhagen

Prepare Apache for virtual hosts A virtual host is a web site controlled by a web server. The configuration of the virtual host is kept in a ”*.conf” file accessible by the web server program (on Redhat:”httpd” on Debian: ”apache2”). Typically these files are organized as one file for each site controlled by the web server and are located somewhere in the /etc/httpd folder (Debian: /etc/apache2). A practal way to organize the files is to keep the actual *.conf files in a folder of available site and symlink to them from a folder of active sites (so the sites becomes active when there is a symlink and inactive when the symlink is removed) First create two folders in /etc/httpd folder

cd /etc/httpd mkdir sites-available mkdir sites-enabled

Next make sure Apache sees the symlinked files by adding a line to the httpd.conf file

nano conf/httpd.conf

Add this line to the end

IncludeOptional sites-enabled/*.conf

save the file (ctrl+o,ctrl+x)

Setup the virtual host An important part of running a web site is to log errors and access. By default Apache writes all logs for all virtual hosts to the same files (usally in the folder /var/log/httpd or /var/log/apache) To keep logs organized it may be better to keep the logs of each virtual host in separate files. In this case I will keep logs from the dbNP/GSCF file in a folder named gscf that I will create in the apache log folder Create a folder ”gscf” in the apache log folder

cd /var/log/httpd mkdir gscf

The full path of this folder is ”/var/log/httpd/gscf” Next I will create the file that defines the virtual host (it wil be called ”gscf.conf”)

cd /etc/httpd nano sites-available/gscf.conf

Page 18: How to install dbNP/GSCF with java 8, tomcat 8, Apache ... · Most of the commands in this tutorial need to be executed as ”root”, so the easiest is to just ”become root”

Tutorial: Install dbNP on CentOS/RHEL 7 (v3) 18/24 PhenotypeDatabase / GSCF

Finn Sandø – Department of Nutrition, Exercise and Sports (NEXS) – University of Copenhagen

The full content of the file (this is almost verbatim copy-paste from the PhenotypeDatabase github page)

<VirtualHost *:80> ServerName mysite.com ServerAlias gscf.mysite.com # keep error and access logs in a separate dedicated folder # the folder must exist before trying to run this site ErrorLog /var/log/gscf/error_log CustomLog /var/log/gscf/access_log combined <IfModule mod_rewrite.c> RewriteEngine on # keep listening for the serveralias, but redirect to # servername instead to make sure only one user session # is created (tomcat will create one user session per # domain which may lead to two (or more) usersessions # depending on the number of serveraliases) # see gscf ticket #321 RewriteCond %{HTTP_HOST} ^test.gscf.mysite.com$ [NC] RewriteRule ^(.*)$ http://test.mysite.com$1 [R=301,L] # rewrite the /gscf-a.b.c-environment/ part of the url RewriteCond %{HTTP_HOST} ^test.mysite.com$ [NC] RewriteRule ^/gscf/(.*)$ /$1 [L,PT,NC,NE] </IfModule> <IfModule mod_proxy.c> <Proxy *> Order deny,allow Allow from all </Proxy> ProxyStatus On ProxyPass / balancer://gscf-cluster/gscf/ stickysession=JSESSIONID|jsessionid nofailover=On ProxyPassReverse / balancer://gscf-cluster/gscf/ ProxyPassReverseCookiePath /gscf / <Location /> SetOutputFilter proxy-html ProxyHTMLDoctype XHTML Legacy ProxyHTMLURLMap /gscf/ / </Location> <Proxy balancer://gscf-cluster> BalancerMember ajp://localhost:8009 </Proxy> </IfModule> </VirtualHost>

Save and restart apache (ctrl+0,ctrl+x)

systemctl restart httpd

Page 19: How to install dbNP/GSCF with java 8, tomcat 8, Apache ... · Most of the commands in this tutorial need to be executed as ”root”, so the easiest is to just ”become root”

Tutorial: Install dbNP on CentOS/RHEL 7 (v3) 19/24 PhenotypeDatabase / GSCF

Finn Sandø – Department of Nutrition, Exercise and Sports (NEXS) – University of Copenhagen

Installing dbNP/GSCF

As mentioned in the Tomcat setup section there are several ways to in install a webapp in Tomcat. In this section I am going to do a manual installation of the GSCF app. In the Tomcat folder is a subfolder named ”webapps” all the webapps controlled by Tomcat resides in this folder as subfolders (the PhenotypeDatabase webapp is going to be installed in a subfolder named ”gscf”) First we need to download the latest version of the PhenotypeDatabase

mkdir dbnp cd dbnp wget http://download.dbnp.org/production/PhenotypeDatabase.war

Next upzip the downloaded file directly to the tomcat webapps folder

unzip PhenotypeDatabase.war -d /opt/tomcat/webapps/gscf

List the content of the gscf folder

ls -l /opt/tomcat/webapps/gscf/ total 28 drwxr-xr-x 4 root root 4096 Mar 22 19:25 css drwxr-xr-x 2 root root 4096 Mar 22 19:25 downloads drwxr-xr-x 2 root root 6 Mar 22 19:25 fileuploads drwxr-xr-x 15 root root 4096 Mar 22 19:25 images drwxr-xr-x 7 root root 4096 Mar 22 19:25 js drwxr-xr-x 2 root root 24 Mar 22 19:25 META-INF drwxr-xr-x 11 root root 4096 Mar 22 19:25 plugins -rw-r--r-- 1 root root 233 Sep 8 2015 robots.txt drwxr-xr-x 9 root root 4096 Mar 22 19:25 WEB-INF drwxr-xr-x 2 root root 37 Mar 22 19:25 webtestfiles

Side note on other ways to install: Another way to do the install is to copy the original zipped war file to the tomcat/webapps folder, restart Tomcat and let Tomcat automatically unzip and install it. It appears that Tomcat will create a subfolder of the same name as the war-file, therefore if you choose this method you will need to rename the PhenotypeDatabase.war to gscf.war The third way is to upload the file via the Manager App web interface – I have not tested this fully to a successful working installation.

Page 20: How to install dbNP/GSCF with java 8, tomcat 8, Apache ... · Most of the commands in this tutorial need to be executed as ”root”, so the easiest is to just ”become root”

Tutorial: Install dbNP on CentOS/RHEL 7 (v3) 20/24 PhenotypeDatabase / GSCF

Finn Sandø – Department of Nutrition, Exercise and Sports (NEXS) – University of Copenhagen

Configuring dbNP/GSCF First create a subfolder ”.gscf” (note that it starts with a dot) in the tomcat folder

cd /opt/tomcat mkdir .gscf

Next find the default example config file (webapps/gscf/WEB-INF/classes/default.properties) and copy it to ”.gscf”

cp webapps/gscf/WEB-INF/classes/default.properties .gscf

Edit the file (ctrl+o to save, ctrl+x to leave)

nano .gscf/production.properties

I will go through this setup section for section The default file

## Server URL ## grails.serverURL=http://localhost:8080/gscf

Server URL

The server URL is used throughout this file, therefore it is better to create a variable to hold this value In this example the domain name is ”dashin-n04.vm” like this

ipaddr=dashin-n04.vm

This can then be used where needed like this

${ipaddr}

Consequently:

## Server URL ## ipaddr=dashin-n04.vm grails.serverURL=http://${ipaddr}:8080/gscf gscf.baseURL=http://${ipaddr}:8080/gscf

Page 21: How to install dbNP/GSCF with java 8, tomcat 8, Apache ... · Most of the commands in this tutorial need to be executed as ”root”, so the easiest is to just ”become root”

Tutorial: Install dbNP on CentOS/RHEL 7 (v3) 21/24 PhenotypeDatabase / GSCF

Finn Sandø – Department of Nutrition, Exercise and Sports (NEXS) – University of Copenhagen

The database disable the in-memory database, enable postgres default

… ## In-Memory Database ## dataSource.driverClassName=org.h2.Driver dataSource.url=jdbc:h2:mem:devDB dataSource.dbCreate=create-drop dataSource.username=sa dataSource.password= ## Database (disable in-memory database first) ## # dataSource.driverClassName=org.postgresql.Driver # dataSource.dialect=org.hibernate.dialect.PostgreSQLDialect # dataSource.url=jdbc:postgresql://localhost:5432/gscf-www # dataSource.dbCreate=update # dataSource.username=<gscfuser> # dataSource.password=<password> ...

My changes

... ## In-Memory Database ## #dataSource.driverClassName=org.h2.Driver #dataSource.url=jdbc:h2:mem:devDB #dataSource.dbCreate=create-drop #dataSource.username=sa #dataSource.password= ## Database (disable in-memory database first) ## dataSource.driverClassName=org.postgresql.Driver dataSource.dialect=org.hibernate.dialect.PostgreSQLDialect dataSource.url=jdbc:postgresql://localhost:5432/gscfwww dataSource.dbCreate=update dataSource.username=gscfuser dataSource.password=secret-pw ...

Note: The database name (without dash) Enable modules

... ## Module Configuration ## modules.showInMenu=true modules.sam.baseurl=http://localhost:8080/gscf/measurements/SAM modules.sam.url=gscf/measurements/SAM # modules.metabolomics.url=http://localhost:8083/metabolomicsModule # modules.massSequencing.url=http://localhost:8184/massSequencing ...

My changes

... ## Module Configuration ## modules.showInMenu=true modules.sam.baseurl=http://${ipaddr}:8080/gscf/measurements/SAM modules.sam.url=gscf/measurements/SAM modules.metabolomics.url=http://${ipaddr}:8083/metabolomicsModule modules.massSequencing.url=http://${ipaddr}:8184/massSequencing ...

Page 22: How to install dbNP/GSCF with java 8, tomcat 8, Apache ... · Most of the commands in this tutorial need to be executed as ”root”, so the easiest is to just ”become root”

Tutorial: Install dbNP on CentOS/RHEL 7 (v3) 22/24 PhenotypeDatabase / GSCF

Finn Sandø – Department of Nutrition, Exercise and Sports (NEXS) – University of Copenhagen

Default users These user will be written to the database during installation, so passwords can only be changed through the web interface.

... ## Default Application Users ## authentication.users.admin.username=admin authentication.users.admin.password=admiN123! [email protected] authentication.users.admin.administrator=true authentication.users.user.username=user authentication.users.user.password=useR123! [email protected] authentication.users.user.administrator=false ...

My changes

... ## Default Application Users ## authentication.users.admin.username=admin authentication.users.admin.password=adminpw [email protected] authentication.users.admin.administrator=true authentication.users.user.username=user authentication.users.user.password=userpw [email protected] authentication.users.user.administrator=false ...

API key From the PhenotypeDatabase site the API key must be obtained from the Bioportal organization at this address: https://bioportal.bioontology.org Default

... ## Register and get your apikey here: https://bioportal.bioontology.org/account ## bioontology.resturl=http://data.bioontology.org/ bioontology.recommender=http://data.bioontology.org/recommender bioontology.apikey = your-apikey ...

My changes

... ## Register and get your apikey here: https://bioportal.bioontology.org/account ## bioontology.resturl=http://data.bioontology.org/ bioontology.recommender=http://data.bioontology.org/recommender bioontology.apikey = 518e253a-... ...

Page 23: How to install dbNP/GSCF with java 8, tomcat 8, Apache ... · Most of the commands in this tutorial need to be executed as ”root”, so the easiest is to just ”become root”

Tutorial: Install dbNP on CentOS/RHEL 7 (v3) 23/24 PhenotypeDatabase / GSCF

Finn Sandø – Department of Nutrition, Exercise and Sports (NEXS) – University of Copenhagen

Links to documents and downloads Default

... ## Locations of issues and documents ## gscf.issueURL=https://github.com/PhenotypeFoundation/PhenotypeDatabase/issues gscf.documents.quickguide=/interventionstudies/downloads/phenotype_database_quick_guide.pdf gscf.documents.study_manual=/interventionstudies/downloads/phenotype_database_study_manual.pdf gscf.documents.module_manual=/interventionstudies/downloads/phenotype_database_module_manual.pdf gscf.documents.license=/interventionstudies/downloads/phenotype_database_license_terms.pdf ...

My changes

… ## Locations of issues and documents ## gscf.issueURL=https://github.com/PhenotypeFoundation/PhenotypeDatabase/issues gscf.documents.quickguide=downloads/phenotype_database_quick_guide.pdf gscf.documents.study_manual=downloads/phenotype_database_study_manual.pdf gscf.documents.module_manual=downloads/phenotype_database_module_manual.pdf gscf.documents.license=downloads/phenotype_database_license_terms.pdf ...

Email setup Email turned out to be more complicated than expected. I didn't have a certificate on the server so the secure mail connection on port 465 did not work. I had to set it to port 25 (also other changes were needed) Default

... ## Email configuration ## grails.mail.host=smtp.gmail.com grails.mail.port=465 [email protected] grails.mail.password=xxx [email protected] ... ## SpringSecurity E-Mail Settings ## grails.plugin.springsecurity.ui.register.emailFrom=registration@your.domain grails.plugin.springsecurity.ui.forgotPassword.emailFrom=forgot-password@your.domain grails.plugin.springsecurity.ui.forgotPassword.emailSubject="Phenotype Database Password Retrieval" ...

My changes

… ## Email configuration ## grails.mail.host=localhost grails.mail.port=25 grails.mail.username=user1 grails.mail.password=secret-pw [email protected] ... ## SpringSecurity E-Mail Settings ## grails.plugin.springsecurity.ui.register.emailFrom=registration@${ipaddr} grails.plugin.springsecurity.ui.forgotPassword.emailFrom=forgot-password@${ipaddr} grails.plugin.springsecurity.ui.forgotPassword.emailSubject="Phenotype Database Password Retrieval" ...

Page 24: How to install dbNP/GSCF with java 8, tomcat 8, Apache ... · Most of the commands in this tutorial need to be executed as ”root”, so the easiest is to just ”become root”

Tutorial: Install dbNP on CentOS/RHEL 7 (v3) 24/24 PhenotypeDatabase / GSCF

Finn Sandø – Department of Nutrition, Exercise and Sports (NEXS) – University of Copenhagen

Email setup (cont..) (This is probably only needed for insecure connection) Create a new config file in the ”.gscf” folder

cd /opt/tomcat nano .gscf/production.groovy

To find the original groovy config file go to the PhenotypeDatabase github page https://github.com/PhenotypeFoundation/PhenotypeDatabase Browse to this file: grails-app/conf/Config.groovy Look for this part (towards the end of the file) type (or copy) it into the production.groovy file

... // Mail plugin config, also see default.properties or your external config file grails { mail { disabled = false props = [ "mail.smtp.auth": "true", "mail.smtp.socketFactory.port": "465", "mail.smtp.socketFactory.class": "javax.net.ssl.SSLSocketFactory", "mail.smtp.socketFactory.fallback": "false" ] } } ...

Change it into this

// grails settings // Mail plugin config, also see default.properties or your external config file grails { mail { disabled = false props = [ "mail.smtp.auth": "true", "mail.smtp.socketFactory.port": "25", "mail.smtp.socketFactory.class": "javax.net.SocketFactory", "mail.smtp.socketFactory.fallback": "false" ] } }

Restart Tomcat – now everything should be ready to go

systemctl restart tomcat

Vist your new dbNP site