Installing MIRC on a Linux Server
From MircWiki
Any questions, please email me - Tim Phillips timothy.phillips@mh.org.au
This wiki page has been updated to reflect changes in the Linux kernels and Java JAI I/O; and to include some general improvements and typo fixes. Thanks very much to Danny Behar for your feedback. I've tested the re-written instructions (cut and pasting them to make sure there aren't any typos) on Ubuntu 7.10, 8.04, and 8.10 Tim Phillips, Feb 2009.
1 Linux Servers and Distributions
These instructions use the command line interface (CLI) rather than the graphical user interface (GUI), to facilitate installation on a headless Linux server. This has been tested on and hence is written for Ubuntu / Debian. It could be easily adapted for a RedHat / Fedora distribution by changing the apt-get commands to the yum equivalent. Alternatively the Sun JDK packages could be installed from binaries. The below instructions are generic for Linux 2.4 - 2.6 except where stated. Having used a few different Linux distributions for various projects I highly recommend Ubuntu Server (Gutsy 7.10, Hardy 8.04, or Intrepid 8.10). There are known (but easily solved) issues with Sun JAI and the newer Linux kernels used in Ubuntu 8.04 and 8.10 (see below).
1.1 Virtualization (if this means nothing to you ignore this paragraph and keep reading)
The benefits of virtualization are many and beyond the scope of this article. I use and recommend VirtualBox [1] with an optimized Linux distro such as Ubuntu JeOS [2].
2 Two methods of accessing your Linux server
2.1 Locally
This is only an option if your server has a monitor and keyboard and you are sitting in front of it. If you are not already at the command prompt you're probably in the GUI (Gnome, KDE, Xfce etc). You can either press Ctrl+Alt+F1 for a full screen terminal (Alt+F7 to get back to the GUI), or find the gnome-terminal (or equivalent app) in the Applications menu. The latter method is preferable if you're reading these instructions from a web browser.
2.2 Remotely
This is the only option for headless and/or geographically remote Linux servers. The entire installation process can be completed from a text only command line except for the final step (see below). This means that your Linux server needs to have OpenSSH and X Forwarding set up. On most modern Linux servers (certainly on Ubuntu Server) this is part of the default set up. To set it up yourself you need to type the following command after connecting to your server via telnet.
$ sudo apt-get install openssh-server
Connecting to your Linux server with SSH and X forwarding is possible in all three client operating system types, with varying degrees of difficulty
2.2.1 Linux / Unix / Solaris / BSD
$ ssh –Y username@server
You will be asked for the password to match the username, and then you're in.
2.2.2 Mac OS X
Open the Terminal (usually found in Applications, Utilities). In the terminal type the following command.
$ /Applications/Utilities/X11.app/Contents/MacOS/X11
This will open another (X11) terminal window. In here type
$ ssh –Y username@server
You will be asked for the password to match the username, and then you're in.
2.2.3 Microsoft Windows
Download and install Xming X Server for MS Windows [here http://sourceforge.net/project/showfiles.php?group_id=156984&package_id=222154]. Choose the latest Xming package, don't bother with the other packages (fonts etc). Install in MS Windows with all the default options. From your start menu, launch All Programs > Xming > XLaunch. Select Mutliple windows, hit Next, select Start a program, hit Next, select Using PuTTY (plink.exe), enter the IP address of the server and the username into the relevant textboxes, hit Next, uncheck Clipboard, hit Next, hit Finish. You will be asked for the password to match the username, and then you're in.
3 Installation
Now that you're at the command line of your Linux server (either locally or remotely) you can begin installation.
3.1 Download and Install Sun JDK 6
$ sudo apt-get install sun-java6-jdk
3.2 Download and Install Java Advanced Imaging I/O Tools (jai-imageio) 1.1
- To download and install the 32-bit version (for Linux 32-bit installations).
$ cd /usr/lib/jvm/java-6-sun $ sudo wget http://timphillips.net/jai_files/jai_imageio-1_1-lib-linux-i586-jdk.tar.gz $ sudo tar -zxvf ./jai_imageio-1_1-lib-linux-i586-jdk.tar.gz $ sudo rm jai_imageio-1_1-lib-linux-i586-jdk.tar.gz
- To download and install the 64-bit version for (Linux x64 / AMD64).
$ cd /usr/lib/jvm/java-6-sun $ sudo wget http://timphillips.net/jai_files/jai_imageio-1_1-lib-linux-x64-jdk.tar.gz $ sudo tar -zxvf ./jai_imageio-1_1-lib-linux-x64-jdk.tar.gz $ sudo rm jai_imageio-1_1-lib-linux-x64-jdk.tar.gz
This will work on all versions of Ubuntu. If you are curious as to why the files are on timphillips.net and not java.net here is the explanation Java Advanced Imaging I/O on Linux
3.3 Download Apache Tomcat 5.5
$ cd ~ $ wget http://apache.org/dist/tomcat/tomcat-5/v5.5.27/bin/apache-tomcat-5.5.27.tar.gz $ tar -xzvf apache-tomcat-5.5.27.tar.gz $ sudo mv apache-tomcat-5.5.27 /usr/bin/ $ sudo ln -s /usr/bin/apache-tomcat-5.5.27 /usr/bin/tomcat55 $ rm apache-tomcat-5.5.27.tar.gz
3.3.1 (Optional) You can use Tomcat 6.0 if you want
- The latest versions of MIRC (T34gamma at the time of writing) now work with Tomcat v6.0 as well as v5.5.
- I haven't tested this on any of my servers yet (if it ain't broke...) so I haven't changed this wiki page.
- If anyone has any experience with this I'd be interested to know if there was any improvement or problems (email at top/bottom of page).
3.3.2 If the web address for the Tomcat download doesn't work (if it did, ignore this and keep reading)
- If this doesn't work in your part of the world - choose another link at http://tomcat.apache.org/download-55.cgi.
- You want the binary distribution core tar.gz file. See below...
3.4 (Optional) Change the TCP port of Tomcat
The default port setting for Tomcat is 8080 which can be a pain to type in. In this example I have changed the port to 80 (default web port), which is ideal if there is no other web server running on the machine. Its easier for the end user to type in mirc.rmh.org (or whatever your domain name is) than mirc.rmh.org:8080. The remainder of the instructions still have the port at 8080 (for people who skipped this step), so you will need change localhost:8080 to localhost or whichever other port you've chosen.
$ cd /usr/bin/tomcat55/conf $ cp server.xml server-bkp.xml $ perl -pi -e "s/8080/80/g;" server.xml
Once MIRC is set up you will probably be opening at least one other port to receive DICOM objects. This is easily done through the MIRC admin web interface.
3.5 (Optional) Securing Ports on Linux - if your server is in-house only ignore this section and keep reading
If your server is exposed to the internet it needs securing (a firewall).
3.5.1 Ubuntu 7.10
If you want to manually configure your ports (your firewall) using iptables on your linux server you may find this page useful.
3.5.2 Ubuntu 8.04, 8.10
The new module Uncomplicated Firewall or ufw is the easiest and least complicated way of securing your server. ufw is much easier than iptables, which it controls for you.
install ufw
$ sudo apt-get install ufw
set the default behaiviour to deny access
$ sudo ufw default deny
open the port you're using for dicom receiving (change this if its not 104)
$ sudo ufw allow 104
open the ssh interface (so you can control your server remotely)
$ sudo ufe allow ssh
open the web port (80, 8080, 6734... whatever you've chosen)
$ sudo ufw enable 80
or
$ sudo ufw enable 8080
switch it on (it will be on following this command, and after any reboots)
$ sudo ufw enable
3.6 Write a startup script for Tomcat (don't worry I've written it for you)
To successfully run Tomcat certain environment variables are required to tell it where to find Java. These changes can be made to system or user startup configuration files (.bashrc, iptables.rules) but I prefer to script the changes to be made before starting tomcat and undone following tomcat shutting down. That way I can keep track of changes I've made to the system that may not be fresh in my mind when I return to work on the server later on.
$ cd /usr/bin/tomcat55 $ nano tomcat-controller.sh
Paste the following script into the nano editor
#!/bin/sh # ----------------------------------------------------------------------------- # Startup script for Tomcat 5.5 by Tim Phillips Feb09 # Thanks Daniel Behar for pointing out an earlier typo # This script loads the environment variables, # then launches the startup.sh / shutdown.sh # bash scripts that live in the /bin directory. # ----------------------------------------------------------------------------- # Whichever (or both) tomcat scripts we're going to launch - they'll want the environment variables export JAVA_OPTS='-Xms256m -Xmx512m' export JAVA_HOME=/usr/lib/jvm/java-6-sun export CLASSPATH=/usr/bin/tomcat55/common/lib/servlet-api.jar export CLASSPATH=/usr/bin/tomcat55/common/lib/jsp-api.jar # ----------------------------------------------------------------------------- # Check which parameter was passed when this script was called, and act accordingly. # ----------------------------------------------------------------------------- case $1 in start) #startup Apache Tomcat sh /usr/bin/tomcat55/bin/startup.sh ;; stop) #shutdown Apache Tomcat sh /usr/bin/tomcat55/bin/shutdown.sh ;; restart) #shutdown Apache Tomcat sh /usr/bin/tomcat55/bin/shutdown.sh #startup Apache Tomcat sh /usr/bin/tomcat55/bin/startup.sh ;; *) echo "Usage: tomcat-controller start|stop|restart" ;; esac exit 0
Press control-O and Enter to save the file and control-X to exit the nano editor.
Now give the script file executable attributes
$ chmod a+x tomcat-controller.sh
3.7 Test the Tomcat Web Server
$ ./tomcat-controller.sh start
If you have change tomcat to port 80 you will need to start it as sudo (Linux rules about who can open ports <1024)
$ sudo ./tomcat-controller.sh start
You should see something like this...
Using CATALINA_BASE: /home/usr/bin/tomcat55 Using CATALINA_HOME: /home/usr/bin/tomcat55 Using CATALINA_TMPDIR: /home/usr/bin/tomcat55/temp Using JRE_HOME: /usr/lib/jvm/java-6-sun
If you are on a desktop machine (with a GUI) go to http://localhost:80 to see if its working. If you're setting this up on a headless server, access this via your client machine, substituting the hostname for localhost.
Shut Tomcat down
$ ./tomcat-controller.sh stop
or
$ sudo ./tomcat-controller.sh stop
3.8 Download the latest MIRC (T34gamma at the time of writing)
$ cd ~ $ wget http://mirc.rsna.org/T34/MIRCsite-installer-full.jar
3.9 Install MIRC
$ java -jar MIRCsite-installer-full.jar
Further instructions regarding the options presented in the MIRC .jar installer can be found in this section of the Windows installation instructions. MIRC will ask you where tomcat is. If you've been following the above instructions it lives at /usr/bin/tomcat55/ and the installer finds it automatically.
3.10 Test the MIRC Web Service
Restart the Tomcat Server
$ /usr/bin/tomcat-controller.sh start
If you are on a desktop machine (with a GUI) go to http://localhost:8080/mirc/query to see if its working. If you're setting this up on a headless server, access this via your client machine, substituting the hostname for localhost. If you changed the port from 8080 to 80 remember to leave off the 8080 in the above link.
3.11 Install your tomcat script as a startup service in Linux
The below commands will put a copy of your tomcat start up script in the /etc/init.d directory and configure the symlinks to execute the start script when Linux boots and the stop script when it shuts down.
$ sudo cp /usr/bin/tomcat55/tomcat-controller.sh /etc/init.d/ $ sudo update-rc.d tomcat-controller.sh defaults
You should see something like this
/etc/rc0.d/K20tomcat-controller.sh -> ../init.d/tomcat-controller.sh /etc/rc1.d/K20tomcat-controller.sh -> ../init.d/tomcat-controller.sh /etc/rc6.d/K20tomcat-controller.sh -> ../init.d/tomcat-controller.sh /etc/rc2.d/S20tomcat-controller.sh -> ../init.d/tomcat-controller.sh /etc/rc3.d/S20tomcat-controller.sh -> ../init.d/tomcat-controller.sh /etc/rc4.d/S20tomcat-controller.sh -> ../init.d/tomcat-controller.sh /etc/rc5.d/S20tomcat-controller.sh -> ../init.d/tomcat-controller.sh

