JavaEE Training Note - Day 11
Tosay’s topic is related to configuration of service in remote Linux server. The target server is an ubuntu server 16.04. Following are some of configuration steps.
Java (Oracle JDK)
Restricted by legal reasons, the oracle JDK is not available in official source of ubuntu. Therefore, most of times, the oracle JDK requires manual steps to configure. However, on ubuntu environmant, there is a machinism that we can use the package from a personal source, which is PPA, Persnal Package Archive. A personal managed source, that can be subscribed and receive package using the general package management tool in ubuntu (that is APT).
The following step is install oracle JDK 8 via the PPA method on ubuntu environment.
update the system
1sudo apt-get update && sudo apt-get dist-upgraderegister PPA The package has already managed by WebUpd8 team for several years with enough stability.
1sudo add-apt-repository ppa:webupd8team/javaUpdate package list cache
1sudo apt-get updateInstall Java The
oracle-java8-set-defaultpackage will install the corresponsding Java version and update the system configration for alternatives to use oracle JDK as default Java version.1sudo apt-get install oracle-java8-set-default
Tomcat 8.5
A packaged vesion of Apache Tomcat is provided in package source, while it is some kinds of out-of-date. The following steps are used to download leasted release of Tomcat and configure it as a daemon.
Download Download the least relese from https://tomcat.apache.org/download-80.cgi and use the wget tool to save in to server.
12wget http://mirrors.koehn.com/apache/tomcat/tomcat-8/v8.5.11/bin/apache-tomcat-8.5.11.tar.gz \-O ~/tomcat.tar.gzCreate
tomcatuser and group12sudo addgroup --system tomcatsudo adduser --system --ingroup tomcat tomcatUnpack the package Unpack the tarball and modify the user and group property of the package files.
123tar -xvf ~/tomcat.tar.gzsudo mv ~/apache-tomcat-* /home/tomcat/sudo chown tomcat:tomcat -R /home/tomcat/apache-tomcat-*Use authbind the allow binding to 80 port In Linux/Unix environment, the port with port number less then 1024 are privlidged. To manage binding to these port, the authbnf package is a useful package.
1234sudo apt install authbindsudo touch /etc/authbind/byport/{443,80}sudo chmod 500 /etc/authbind/byport/{443,80}sudo chown tomcat:tomcat /etc/authbind/byport/{443,80}Update tomcat server.xml configuration Tomcat configuration file
server.xmlis used to manage hte port and connectivity of the server and its internal conponents. This file is placed inconfpackage of root directory of tomcat.1sudo sed -i 's/8080/80/g' /home/tomcat/apache-tomcat-*/conf/server.xml
This command is to update the following lines:
- Configure systemd to use tomcat as daemon
Edit (create) the systemd configuration entry:
Then add the following content:
(use i to insert, ues <esc>:x to save and quit)
the JAVA_HOME should pointing to root folder of JDK
and the CATALINA_HOME and CATALINA_BASE should
update to tomcat path. (with correct version number).
Enable and start the daemon with systemctl tool