Ubuntu 12.04 – Install Jetty 9
This article will show you how to install Jetty 9 on Ubuntu 12.04. Perform all steps as root.
Jetty requires Java. Install Java first, I prefer openjdk instead of oracle jdk, but it should work both.
apt-get install openjdk-7-jdk
Create a symlink for easier reference from jetty
mkdir /usr/java ln -s /usr/lib/jvm/java-7-openjdk-amd64 /usr/java/default
Go to the opt directory
cd /opt
Download the latest Jetty distribution (9.x).
wget "http://eclipse.org/downloads/download.php?file=/jetty/stable-9/dist/jetty-distribution-9.0.0.M3.tar.gz&r=1" mv download.php\?file\=%2Fjetty%2Fstable-9%2Fdist%2Fjetty-distribution-9.0.0.M3.tar.gz\&r\=1 jetty-distribution-9.0.0.M3.tar.gz
Unpack the archive
tar -xvf jetty-distribution-9.0.0.M3.tar.gz mv jetty-distribution-9.0.0.M3 jetty
Create jetty user and make it the owner of /opt/jetty
useradd jetty -U -s /bin/false chown -R jetty:jetty /opt/jetty
Copy Jetty script to run as service
cp /opt/jetty/bin/jetty.sh /etc/init.d/jetty
Create the settings file /etc/default/jetty
nano /etc/default/jetty
and paste the following in it
JAVA=/usr/bin/java # Path to Java NO_START=0 # Start on boot JETTY_HOST=0.0.0.0 # Listen to all hosts JETTY_ARGS=jetty.port=8085 JETTY_USER=jetty # Run as this user JETTY_HOME=/opt/jetty
Start Jetty as service
service jetty start
It should now be running on port 8085! Visit in your browser http://example.com:8085 and you should see a Jetty screen.
Verify / check your configuration with:
service jetty check
To let Jetty automatically start on reboot execute
update-rc.d jetty defaults
Reboot the server and test if Jetty starts automatically
reboot
To check if Jetty is really running on that port or to see if it conflicts with another application running on that port run
netstat -tln
Remove the unsecure test and async-rest application:
cd /opt/jetty/webapps rm -rf test.d/ test.war test.xml async-rest.war
Or in Jetty 9.0.3:
rm -rf /opt/jetty/webapps.demo
This entry was posted by Pieter Vogelaar on December 30, 2012 at 15:18, and is filed under Ubuntu. Follow any responses to this post through RSS 2.0.You can leave a response or trackback from your own site.
-
-
Hmmm – I’m getting:
sudo /etc/init.d/jetty start
Starting Jetty: FAILEDSo I went and read (as much as I could) /etc/init.d/jetty and tried:
sudo /etc/init.d/jetty supervise
...That works – great! But now I need to set it up so that it always works and is always on…? The most telling message is:
WARNING: System properties and/or JVM args set. Consider using --dry-run or --exec
2013-01-21 17:00:58.872:WARN::main: test-realm is deployed. DO NOT USE IN PRODUCTION!but I can’t see anything online after a quick search that seems relevant?
I’ve checked netstat – there’s nothing else on port 8085…Any ideas what might be wrong?
-
-
Ok, is ok – I’ve worked it out.
There is a problem with jetty/bin/jetty.sh that is explained in great detail here: Ubuntu and Jetty: debugging jetty.sh
-
-
#11 written by Andrey 11 years ago
Thanks, this is very helpful. Btw, Ubuntu wouldn’t let me bind Jetty to port 80 (I changed to 80 where you suggest to use 8085) as jetty user, because only root is allowed to bind to port 80. So eventually I ran Jetty on port 8080, and specified a connection redirect rule from port 80 to 8080 as described here: http://serverfault.com/questions/112795/how-can-i-run-a-server-on-linux-on-port-80-as-a-normal-user
-
#12 written by Andrey 11 years ago
-
#16 written by piccio 11 years ago
I’m using jetty 9.0.3.v20130506
in /etc/default/jetty JETTY_PORT variable it doesn’t work to me
I’ve used
JETTY_ARGS=jetty.port=8085
instead of
JETTY_PORT=8085
(etc/init.d/jetty says that JETTY_PORT is deprecated)same thing to JAVA_HOME
I’ve used
JAVA=/usr/java/default/bin/java
instead of
JAVA_HOME=/usr/java/default
(see /etc/init.d/jetty) -
#18 written by Ameliorator 11 years ago
-
-
#21 written by Nate 11 years ago
I’m using jetty ver 9.0.4.v20130625 on Ubuntu 12.04 and had no problems installing it. Supplying FireFox the URL “http://example.com:8085″ results in a time out.
netstat -tln has an entry with port 8085 under ‘tcp6; but none under ‘tcp’ and we are not using ipv 6.
sudo service jetty check indicates that jetty is running.
(I notice that in jetty/start.ini this line appears in the HTTP Connector section:
jetty.port=8080 )Any ideas of what could be wrong?
Please be gentle as I’m new to all this …. -
#22 written by Nate 11 years ago
I feel as though I’m a person on another forum who often is able to post the answer to his problem before anyone can answer!
Since I tried to connect from Jetty’s host computer I needed to use http//127.0.0.1:8085/
My work lab LAN is really what’s behind my router, no DNS, so I also tested with http//192.168.1.200:8085/ using a WiFi enabled notebook and it worked too (as expected). I should have had more coffee yesterday (or maybe less …).
Now I can move on.
-
#23 written by test 11 years ago
I faced the same problem as #3 dk did as “sudo /etc/init.d/jetty start Starting Jetty: FAILED”
I check the version it uses and java sdk comes with older version and it sets up java 6 ” /usr/lib/jvm/java-6-openjdk-i386/jre/bin/java” as default for some reason. I ran the following command to switch it to java 7.
>sudo update-alternatives –config java
And it starts w/o a problem.
-
#26 written by Vince 11 years ago
-
instead of:
JAVA=/usr/bin/java # Path to Java
NO_START=0 # Start on boot
JETTY_HOST=0.0.0.0 # Listen to all hosts
JETTY_ARGS=jetty.port=8085
JETTY_USER=jetty # Run as this userplease use:
JAVA_HOME=/usr/bin/java # Path to Java
NO_START=0 # Start on boot
JETTY_HOST=0.0.0.0 # Listen to all hosts
JETTY_ARGS=jetty.port=8085
JETTY_USER=jetty # Run as this user -
#30 written by Stef 11 years ago
-
#31 written by pat 10 years ago
-
-
-
#34 written by Sangeetha 10 years ago
Hi ,
I am getting the below error on checking jetty service on Ubuntu 10.04 LTS server.
/etc/default# service jetty check
env: /etc/init.d/jetty: Permission deniedI tried giving
sudo chmod 777 /etc/init.d/jetty – This also did not change the error.I have installed jdk and added jetty user as well.
I have not changed any webapps part.
Below is my etc/default/jetty configuration file./etc/default# cat jetty
JAVA=/usr/bin/java
JETTY_USER=jetty
JETTY_HOST=0.0.0.0. #Listen to all hosts
JETTY_ARGS=jetty.port=8080
JETTY_HOME=/opt/jettyPlease recommend
-
#36 written by Bessie 10 years ago
Hi Pieter,
Firstly thanks for taking the time to put together this post. If I may add my 1 cent, I found creating a link of jetty.sh more helpful. I have found myself counless times using this awsome post, but then making changes to jetty.sh does not take affect. That is because a copy was made of the jetty.sh file.
I suggest running “ln -s /opt/jetty/bin/jetty.sh /etc/init.d/jetty” instead of the cp command.
Hopefully this helps someone else
-
- Ubuntu 12.04 – Install Solr 4 with Jetty 9
- Ubuntu 12.04 – Install Jenkins 1.4 with Jetty 9
- Linux – Jetty – Installation « Gugulethu Ncube
- Linux – Jetty – Installation « Gugulethu Ncube
- Jetty – Installation on Linux « Gugulethu Ncube
- Ubuntu 12.04 – Install Gearman and GearmanManager
- Ubuntu 14.04 – Install Selenium as service (headless)
- Ubuntu 12.04 – Install Postfix, Dovecot and Vimbadmin
- Ubuntu 12.04 – Install Solr 4 with Jetty 9
- Ubuntu 12.04 + Nginx 1.2.6 + PHP-FPM server block / vhost example
- Varnish 3 – Block ip addresses
- Ubuntu 12.04 – Install Varnish 3 in front of Apache 2
- Command “df” in linux shows incorrect free space after file removal
- Ubuntu 11.04 / OpenPanel – Install Webalizer
- Ubuntu 11.10 – Configure POEdit for Zend Framework
About Pieter Vogelaar (60 posts)
Hi, my name is Pieter Vogelaar. I’m a web developer / DevOps engineer / IT consultant and specialized in high traffic and high profile websites. I love open source and have a great passion for automating and developing things!
When you say “Create settings file.” where do we create the file, and what should the file be named?
Awesome article, and please keep up the great work on server configuration and management.