This post describes the basic steps to install the latest version and how to automatically execute Jetty on boot up.
First, we create a shell-script to automate the installation (let's name it install.sh):
1: #!/bin/bash
2:
3: JETTY_VERSION=7.0.2.v20100331
4: wget http://download.eclipse.org/jetty/$JETTY_VERSION/dist/jetty-distribution-$JETTY_VERSION$
5: tar xfz jetty-distribution-$JETTY_VERSION.tar.gz -C /opt
6: ln -fs /opt/jetty-distribution-$JETTY_VERSION /opt/jetty
7: cp /opt/jetty/bin/jetty.sh /etc/init.d
8: update-rc.d jetty.sh defaults
So, what does it do?
The first line should be self-explanatory. It invokes bash, and passes the name of the script being executed to it.
On the third line, we set the version we like to install (refer to Jetty@eclipse downloads to find out the latest version). The advantage of storing the version in a shell variable and referencing the variable instead of hard coding the version number is that if a new version gets released, we only need to change the version number, and the script will install the new version without any additional changes.
Next, we download Jetty using the wget command (notice how we reference JETTY_VERSION) and extract the downloaded archive using the tar command (the -C option puts the extracted files to /opt).
Then, we create a symbolic link to the extracted Jetty distribution named jetty (the -f option makes sure that future invocations of to the script update the symbolic link reference accordingly). This is necessary so that the init script, which we will copy in the next step, will be able to locate the Jetty installation.
On the sixth line, the init script (which is already provided by Jetty) is copied to /etc/init.d, which contains the scripts executed by the init process at boot up.
Last, but not least, we run update-rc.d jetty.sh defaults, which makes links that point to the script /etc/init.d/jetty (for further details, refer to update-rc.d's manpage).
Now we only have to make the script executable (the mode u+x grants execute permission to the owner of the script):
$ sudo chmod u+x install.sh
and execute it as the superuser:
$ sudo ./install.sh
Reboot the system, and in your preferred browser type:
http://localhost:8080
You should see a web application similar to this one:
Et voilà, you've just installed Jetty 7 on Debian.