wget http:\/\/download.oracle.com\/otn-pub\/java\/jdk\/10.0.1+10\/fb4372174a714e6b8c52526dc134031e\/jdk-10.0.1_linux-x64_bin.tar.gz?AuthParam=1524098700_a9d659266ceb23794153d6c6060cdc44 -O jdk-10.0.1_linux-x64_bin.tar.gz<\/pre>\nExtract the tarball.<\/p>\n
tar -xzvf jdk-10.0.1_linux-x64_bin.tar.gz<\/pre>\nNow, let’s create some environment variables<\/p>\n
nano \/etc\/profile.d\/tomcat9<\/pre>\nAdd the following lines to the file:<\/p>\n
export CATALINA_HOME=\"\/usr\/local\/apache-tomcat-10.0.1\"\r\nexport JAVA_HOME=\"\/usr\/lib\/jvm\/jdk-10.0.1\"\r\nexport JRE_HOME=\"\/usr\/lib\/jvm\/jdk-10.0.1\/jre\"<\/pre>\nRun this command to load the environment variables now:<\/p>\n
source \/etc\/profile.d\/tomcat9<\/pre>\nConfigure the newly installed Oracle Java JDK as default on your system. Invoke the following commands:<\/p>\n
update-alternatives --install \"\/usr\/bin\/java\" \"java\" \"\/usr\/lib\/jvm\/jdk-10.0.1\/bin\/java\" 1\r\nupdate-alternatives --install \"\/usr\/bin\/javac\" \"javac\" \"\/usr\/lib\/jvm\/jdk-10.0.1\/bin\/javac\" 1\r\nupdate-alternatives --install \"\/usr\/bin\/javaws\" \"javaws\" \"\/usr\/lib\/jvm\/jdk-10.0.1\/bin\/javaws\" 1<\/pre>\nLet’s correct the permissions and ownership of the executable files<\/p>\n
chmod a+x \/usr\/bin\/java\r\nchmod a+x \/usr\/bin\/javac\r\nchmod a+x \/usr\/bin\/javaws\r\nchown -R root: \/usr\/lib\/jvm\/jdk-10.0.1<\/pre>\nNow, let’s run this command:<\/p>\n
update-alternatives --config java<\/pre>\nIf you see the following message:<\/p>\n
There is only one alternative in link group java (providing \/usr\/bin\/java): \/usr\/lib\/jvm\/jdk-10.0.1\/bin\/java\r\nNothing to configure.<\/pre>\nIt means that you have never installed Java before, you installed it just now.
\nIf you see another message, containing Java versions to choose from, then you have installed another Java version before.<\/p>\n
<\/span>4. Install Tomcat 9 on Debian 9<\/span><\/h2>\nNow, let’s proceed with the Apache Tomcat 9 installation<\/p>\n
Go to Apache Tomcat official download website http:\/\/tomcat.apache.org\/download-90.cgi and download the tarball version under Core<\/p>\n
curl -O http:\/\/apache.mirrors.tds.net\/tomcat\/tomcat-9\/v9.0.7\/bin\/apache-tomcat-9.0.7.tar.gz<\/pre>\nExtract the tarball using the following command:<\/p>\n
tar -xzvf apache-tomcat-9.0.7.tar.gz<\/pre>\nThen, move the uncompressed directory to \/opt<\/p>\n
mv apache-tomcat-9.0.7 \/opt\/tomcat<\/pre>\nAs this stage, the tomcat directory is owned by root.
\nFor security reasons, it is not recommended to run Tomcat as user root, so we will create a new system user<\/p>\n
useradd -r tomcat9 --shell \/bin\/false<\/pre>\nChange the ownership of the extracted directory to tomcat user we created just now.<\/p>\n
chown -R tomcat9: \/opt\/tomcat\/<\/pre>\n<\/span>5. Create Tomcat 9 user account<\/span><\/h2>\nYou can create a new Tomcat user in order to be able to access the Tomcat manager. Open the tomcat-users.xml file and add the following lines:<\/p>\n
nano \/opt\/tomcat\/conf\/tomcat-users.xml\r\n\r\n<role rolename=\"admin-gui\" \/>\r\n<user username=\"admin\" password=\"PASSWORD\" roles=\"manager-gui,admin-gui\"\r\n<\/tomcat-users><\/pre>\nDon\u2019t forget to replace PASSWORD with an actual strong password.<\/p>\n