Skip to content

XNAT Ubuntu 12.04.3 Server Installation

dgutman edited this page Dec 21, 2013 · 21 revisions

Guide to Installation of latest version of XNAT on Ubuntu 12.04.3 LTS

#so this is personal preference, but I initially set up my machine with my userID during
#initial installation of the ubuntu 12.04LTS system`
# however I prefer to run XNAt as the "xnat" user... so once I login the first time I do`
sudo adduser xnat
#and then it asks me for a pssword for the xnat user--- I then disconnect and reconnect`
# also once the XNAT user is added-- you want to add them either to the admin group or edit the /etc/sudoers 
# and add an entry for the  xnat user so you can actually sudo...`

sudo apt-get install python-software-properties ## installs the add-apt-repository utility
sudo apt-get purge openjdk*   
sudo add-apt-repository ppa:webupd8team/java  
sudo apt-get update  `
sudo apt-get install oracle-java7-installer`
echo "export JAVA_HOME=/usr/lib/jvm/java-7-oracle/" >> ~/.bashrc
source ~/.bashrc
sudo apt-get install tomcat7
sudo apt-get install tomcat7-user
`## Remove primary Tomcat init script
## http://www.debuntu.org/how-to-manage-services-with-update-rc.d
sudo update-rc.d -f tomcat6 remove
##reboot


## need to create the appropriate directories for XNAT FILES

## I am running A VM, but I created the VM with two hard drives-- one independent and one not
## this allows me to have local file storage, but still be able to do snapshots/revisions/and back up the database
## the second hard drive appears as /dev/sdb
sudo fdisk /dev/sdb
#http://tldp.org/HOWTO/Partition/fdisk_partitioning.html
#hit p for primary, then 1 for partition number
#then his enter twice and w to write
sudo mkfs -t ext4 /dev/sdb1
sudo mount /dev/sdb1 /Library

# put an entry in /etc/fstab so it gets mounted on boot
# /dev/sdb1   /Library   ext4 defaults 0 0

sudo mkdir -p /Library/XNAT
sudo chown xnat:xnat /Library/XNAT
mkdir /Library/XNAT/archive
mkdir /Library/XNAT/prearchive
mkdir /Library/XNAT/build
mkdir /Library/XNAT/ftp
mkdir /Library/XNAT/cache
mkdir /Library/XNAT/modules



##after reboot
tomcat7-instance-create tomcat
## Setup database
## Modify configuration files
echo "localhost:*:xnat01:xnat01:xnat01" >> ~/.pgpass
chmod 600 ~/.pgpass
### this creates a database xnat01 for user xnat01 with pass... xnat01

## Setup database
sudo apt-get install postgresql

# run these as the postgres user, e.g. first do $ sudo su - postgres
# or use 'sudo -u postgres' in front of the commands
createuser -S -D -R -P xnat01 # will prompt for password
createdb -O xnat01 xnat01
# return to xnat user

wget ftp://ftp.nrg.wustl.edu/pub/xnat/xnat-1.6.2.1.hg.tar.gz
tar -zxvf xnat-1.6.2.1.hg.tar.gz
mv xnat xnat-1.6.2.1
cd xnat-1.6.2.1

## I'm old school so using nano
cp build.properties.sample build.properties
nano build.properties

## I changed the db.user and db.name to xnat01, as well as dbname and the last part of the connection string
# modified the mail service as well.. for me it's smtp.service.emory.edu

cd ~/xnat-1.6.2.1
## DO NOT TRY AND UPDATE TO THE LATEST MERCURIAL BUILD.. THIS KILLED ME..  apt-get install mercurial
## this goes to the mercurial repo and pulls the absolute latest hg version
#hg pull   <<DONT DO THIS!!!>>
#sudo apt-get install mercurial

chmod +x bin/
./bin/setup.sh
### JAVA_HOME MUST BE SET OR THIS GOES BADLY!!

psql -d xnat -f deployments/xnat/sql/xnat.sql
## in my case it was psql -d xnat01 -f deployments/xnat_vault/sql/xnat_vault.sql

# add this to .bashrc export XNAT_HOME=/home/xnat/xnat-1.6.2.1
#nt variable called XNAT_HOME with the directory pointing to your XNAT_HOME directory. Use this variable to #add the bin directory to your path environment variable (i.e. PATH=$PATH:$XNAT_HOME/bin). 

cd deployments/xnat  ## i actually installed to xnat_vault so cd'd there
StoreXML -l security/security.xml -allowDataDeletion true

StoreXML -dir ./work/field_groups -u admin -p admin -allowDataDeletion true



### default pipeline.config properties are not set 
pwd ~/xnat-1.6.2.1/pipeline/config
mkdir /Library/XNAT/tmp
nano XnatPipeLauncher.config
## change the XNAT_PIPELINE_LAUNCHER_OPTS
XNAT_PIPELINE_LAUNCHER_OPTS=" -Xms256m -Xmx1024m -XX:MaxPermSize=256m  -Dpipeline.tmp=/Librarry/XNAT/tmp"