{"id":17647,"date":"2015-09-16T13:05:55","date_gmt":"2015-09-16T18:05:55","guid":{"rendered":"https:\/\/secure.rosehosting.com\/blog\/?p=17647"},"modified":"2022-12-16T03:25:35","modified_gmt":"2022-12-16T09:25:35","slug":"install-jetty-on-a-centos-7-vps","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/install-jetty-on-a-centos-7-vps\/","title":{"rendered":"Install Jetty on a CentOS 7 VPS"},"content":{"rendered":"
In the following article we are going to explain how you can install Jetty on a CentOS 7 VPS<\/a>.<\/p>\n Jetty is a Java HTTP (Web) server and Java Servlet container and provides support for SPDY, WebSocket, OSGi, JMX, JNDI, JAAS and many other integrations. It is often used for machine to machine communications, within larger software frameworks. Jetty is developed as a free and open source project as part of the Eclipse Foundation.<\/p>\n Jetty is used in a wide variety of projects and products, both in development and production. It can be easily embedded in devices, tools, frameworks, application servers, and clusters.<\/p>\n Jetty has the following features:<\/p>\n <\/p>\n REQUIREMENTS<\/strong><\/p>\n We will be using our CentOS 7 minimal Linux VPS<\/a> template for this tutorial.<\/p>\n UPDATE THE SYSTEM<\/strong><\/p>\n As always, make sure your server is fully up-to-date with the command below:<\/p>\n Also, install unzip and a text editor of your choice. We will use nano as our text editor:<\/p>\n INSTALL AND SETUP JAVA<\/strong><\/p>\n Jetty requires JAVA in order to run. We are going to install the latest version of Oracle\u2019s JAVA JDK 8. At the time of writing this article, the latest version of JAVA is 8u60<\/span> and can be downloaded and installed using the command below:<\/p>\n Install JAVA:<\/p>\n Configure the JAVA package using the alternatives command:<\/p>\n You may want to check if JAVA has been properly setup on your server using:<\/p>\n INSTALL JETTY<\/strong><\/p>\n We will download and unpack the Jetty installation archive into the \/opt<\/em><\/strong> directory. Currently, while this article has been written, the latest Jetty version is 9.3.3, so we will download that one. Enter the following commands:<\/p>\n Rename the Jetty installation directory into one with an easier name:<\/p>\n Create a user called Jetty and configure the correct file ownership:<\/p>\n Symlink the jetty.sh script to the \/etc\/init.d\/ directory to create a start up script file:<\/p>\n Add the script:<\/p>\n Configure Jetty to start on system boot:<\/p>\n Now, you need to create a configuration file for Jetty. Open a file:<\/p>\n Now paste the following:<\/p>\n Don’t forget to add your server IP address in the JETTY_HOST line.<\/p>\n Navigate to the Jetty installation directory:<\/p>\n Next, delete the webapps directory since there is nothing in it and copy the webapps directory from demo-base. It is a test and demo data from Jetty.<\/p>\n Start Jetty:<\/p>\n With the curl command test if you can retrieve the index page.<\/p>\n Or open your favorite web browser and navigate to http:\/\/your_server_IP:8080<\/strong> after which you will see the welcome page like the image below:<\/p>\n <\/p>\n Congratulations. You have successfully installed Jetty on your CentOS 7 VPS<\/a>. You can now check the Jetty documentation<\/a> for more information.<\/p>\n Of course you don\u2019t have to do any of this if you use one of our Linux VPS Hosting<\/a> services, in which case you can simply ask our expert Linux admins to install Jetty for you. They are available 24\u00d77 and will take care of your request immediately.<\/p>\n PS.<\/span> If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.<\/p>\n","protected":false},"excerpt":{"rendered":" In the following article we are going to explain how you can install Jetty on a CentOS 7 VPS. Jetty … <\/p>\n\n
# yum update<\/pre>\n
# yum install nano unzip<\/pre>\n
# wget --no-cookies --no-check-certificate --header \"Cookie: oraclelicense=accept-securebackup-cookie\" \"http:\/\/download.oracle.com\/otn-pub\/java\/jdk\/8u60-b27\/jdk-8u60-linux-x64.rpm\" -O \/opt\/jdk-8-linux-x64.rpm<\/pre>\n
# yum install \/opt\/jdk-8-linux-x64.rpm<\/pre>\n
# JDK_DIRS=($(ls -d \/usr\/java\/jdk*))\r\n\r\n# JDK_VER=${JDK_DIRS[@]:(-1)}\r\n\r\n# alternatives --install \/usr\/bin\/java java \/usr\/java\/\"${JDK_VER##*\/}\"\/jre\/bin\/java 20000\r\n\r\n# alternatives --install \/usr\/bin\/jar jar \/usr\/java\/\"${JDK_VER##*\/}\"\/bin\/jar 20000\r\n\r\n# alternatives --install \/usr\/bin\/javac javac \/usr\/java\/\"${JDK_VER##*\/}\"\/bin\/javac 20000\r\n\r\n# alternatives --install \/usr\/bin\/javaws javaws \/usr\/java\/\"${JDK_VER##*\/}\"\/jre\/bin\/javaws 20000\r\n\r\n# alternatives --set java \/usr\/java\/\"${JDK_VER##*\/}\"\/jre\/bin\/java\r\n\r\n# alternatives --set javaws \/usr\/java\/\"${JDK_VER##*\/}\"\/jre\/bin\/javaws\r\n\r\n# alternatives --set javac \/usr\/java\/\"${JDK_VER##*\/}\"\/bin\/javac\r\n\r\n# alternatives --set jar \/usr\/java\/\"${JDK_VER##*\/}\"\/bin\/jar<\/pre>\n
# java -version<\/pre>\n
# cd \/opt\r\n\r\n# wget http:\/\/eclipse.mirror.rafal.ca\/jetty\/stable-9\/dist\/jetty-distribution-9.3.3.v20150827.zip\r\n\r\n# unzip jetty-distribution-9.3.3.v20150827.zip<\/pre>\n
# mv jetty-distribution-9.3.3.v20150827 jetty<\/pre>\n
# useradd -m jetty\r\n\r\n# chown -R jetty:jetty \/opt\/jetty\/<\/pre>\n
# ln -s \/opt\/jetty\/bin\/jetty.sh \/etc\/init.d\/jetty<\/pre>\n
# chkconfig --add jetty<\/pre>\n
# chkconfig --level 345 jetty on<\/pre>\n
# nano \/etc\/default\/jetty<\/pre>\n
JETTY_HOME=\/opt\/jetty\r\nJETTY_USER=jetty\r\nJETTY_PORT=8080\r\nJETTY_HOST=your_server_IP\r\nJETTY_LOGS=\/opt\/jetty\/logs\/<\/pre>\n
# cd \/opt\/jetty<\/pre>\n
# rm -rf webapps\/\r\n\r\n# cp -r demo-base\/webapps\/ \/opt\/jetty\/<\/pre>\n
# service jetty start<\/pre>\n
# curl localhost:8080<\/pre>\n