How To Install Tomcat9 On Linuxmint 18.3
To Install Tomcat9 On Linux Mint 18.3
Apache Tomcat is an open source web server and servlet container developed by the Apache Software Foundation. It executes Java servlets and renders Web pages that include Java Server Page coding and it is one of the most popular web servers used by the Java developers. It is so simple to install Tomcat9 on Linux Mint 18.3 and this tutorial covers the ground on the same process.
Installing Tomcat9
In order to install Tomcat, it is really very essential to install Java, so make sure you run the following command.
linuxhelp ~ # apt-get install default-jdk
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
ca-certificates-java default-jdk-headless default-jre default-jre-headless openjdk-8-jdk openjdk-8-jdk-headless openjdk-8-jre
openjdk-8-jre-headless
Suggested packages:
default-java-plugin openjdk-8-demo openjdk-8-source visualvm icedtea-8-plugin fonts-ipafont-gothic fonts-ipafont-mincho fonts-wqy-zenhei
Recommended packages:
.
.
Processing triggers for libc-bin (2.23-0ubuntu9) ...
Processing triggers for ca-certificates (20170717~16.04.1) ...
Updating certificates in /etc/ssl/certs...
0 added, 0 removed done.
Running hooks in /etc/ca-certificates/update.d...
done.
done.
Once it is done, you can check if it' s installed properly by making use of the following command which displays the version of Java.
linuxhelp ~ # java -version
openjdk version " 1.8.0_151"
OpenJDK Runtime Environment (build 1.8.0_151-8u151-b12-0ubuntu0.16.04.2-b12)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)
After that, you should create a user for Tomcat.
linuxhelp ~ # useradd -r tomcat9 --shell /bin/false
And then, you need to enter into /opt location to download the apache-tomcat9.
linuxhelp ~ # cd /opt/
linuxhelp opt #
Now, you shall download tomcat9 package by using the wget command in the following manner.
linuxhelp opt # wget http://www-eu.apache.org/dist/tomcat/tomcat-9/v9.0.6/bin/apache-tomcat-9.0.6.tar.gz
--2018-03-24 04:37:07-- http://www-eu.apache.org/dist/tomcat/tomcat-9/v9.0.6/bin/apache-tomcat-9.0.6.tar.gz
Resolving www-eu.apache.org (www-eu.apache.org)... 195.154.151.36, 2001:bc8:2142:300::
Connecting to www-eu.apache.org (www-eu.apache.org)|195.154.151.36|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9494739 (9.1M) [application/x-gzip]
Saving to: ‘ apache-tomcat-9.0.6.tar.gz’
apache-tomcat-9.0.6.tar.gz 100%[===================================================================> ] 9.05M 43.8MB/s in 0.2s
2018-03-24 04:37:37 (43.8 MB/s) - ‘ apache-tomcat-9.0.6.tar.gz’ saved [9494739/9494739]
After that, make sure you extract the downloaded file by using the following command.
linuxhelp opt # tar -xzf apache-tomcat-9.0.6.tar.gz
linuxhelp opt # ls
apache-tomcat-9.0.6 apache-tomcat-9.0.6.tar.gz
You should also create the symbolic link for an extracted directory by making use of the following command.
linuxhelp opt # ln -s apache-tomcat-9.0.6 tomcat-latest
And then, you should change the ownership of the extracted directory by running the following command.
linuxhelp opt # chown -hR tomcat9: tomcat-latest apache-tomcat-9.0.6
Next, you should create a user for manager and admin in the tomcat-user file as follows.
linuxhelp opt # vim tomcat-latest/conf/tomcat-users.xml
< role rolename=" manager-gui" />
< role rolename=" admin-gui" />
< user username=" admin" password=" password" roles=" manager-gui,admin-gui" />
Next, make an entry to allow the server.
linuxhelp opt # vim tomcat-latest/webapps/manager/META-INF/context.xml < Context antiResourceLocking=" false" privileged=" true" > < Valve className=" org.apache.catalina.valves.RemoteAddrValve" allow=" 127.d+.d+.d+|::1|0:0:0:0:0:0:0:1|192.168.7.232" /> < Manager sessionAttributeValueClassNameFilter=" java.lang.(?:Boolean|Integer|Long|Number|String)|org.apache.catalina.filters.CsrfPreventionFilter$LruCache(?:$1)?|java.util.(?:Linked)?HashMap" /> < /Context> linuxhelp opt # vim tomcat-latest/webapps/host-manager/META-INF/context.xml < Context antiResourceLocking=" false" privileged=" true" > < Valve className=" org.apache.catalina.valves.RemoteAddrValve" allow=" 127.d+.d+.d+|::1|0:0:0:0:0:0:0:1|192.168.7.232" /> < Manager sessionAttributeValueClassNameFilter=" java.lang.(?:Boolean|Integer|Long|Number|String)|org.apache.catalina.filters.CsrfPreventionFilter$LruCache(?:$1)?|java.util.(?:Linked)?HashMap" /> < /Context>
Configure daemon file for start and stop tomcat service.
linuxhelp opt # vim /etc/systemd/system/tomcat.service
[Unit]
Description=Tomcat9
After=network.target
[Service]
Type=forking
User=tomcat9
Group=tomcat9
Environment=CATALINA_PID=/opt/tomcat-latest/tomcat9.pid
Environment=JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
Environment=CATALINA_HOME=/opt/tomcat-latest
Environment=CATALINA_BASE=/opt/tomcat-latest
Environment=" CATALINA_OPTS=-Xms512m -Xmx512m"
Environment=" JAVA_OPTS=-Dfile.encoding=UTF-8 -Dnet.sf.ehcache.skipUpdateCheck=true -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:+UseParNewGC"
ExecStart=/opt/tomcat-latest/bin/startup.sh
ExecStop=/opt/tomcat-latest/bin/shutdown.sh
[Install]
WantedBy=multi-user.target
~
~
~
And then, reload daemon with the help of the following command.
linuxhelp opt # systemctl daemon-reload
You shall now start the Tomcat service by running the following command.
linuxhelp opt # systemctl start tomcat.service
Also, you need to enable the Tomcat service through the following command.
linuxhelp opt # systemctl enable tomcat.service
Created symlink from /etc/systemd/system/multi-user.target.wants/tomcat.service to /etc/systemd/system/tomcat.service.
Now, open your browser and give localhost:8080 as the URL. The home page of Tomcat appears on your screen.
If you want to open the manager app, then click on it. And give your login credentials in the popup that appears.
The Manager page of Tomcat now appears.
If you want to open the VirtualHost for the admin panel, then click on Host manage.
With this, the installation of Tomcat9 on Linux Mint 18.3 comes to an end.
Comments ( 0 )
No comments available