Install Java and Apache Tomcat (Ubuntu)
Install Java and Apache Tomcat (Ubuntu)
Installation and Configuration > Installing ThingWorx > Ubuntu Installation > PostgreSQL > Install Java and Apache
Tomcat (Ubuntu)
https://support.ptc.com/help/thingworx_hc/thingworx_8_hc/en/index.html#page/ThingWorx/Help/Installation/Installation/install_java_and_apache_tomcat__ub… 1/6
12/24/21, 3:55 PM Install Java and Apache Tomcat (Ubuntu)
14. Download Apache Tomcat: The steps in this process use Tomcat 8.5.xx, where xx is
replaced with the version you are using.
$ wget http://archive.apache.org/dist/tomcat/tomcat-8/v8.5.xx/bin/apache-tomcat-8.5.xx.t
Best practice includes verifying the integrity of the Tomcat file by using the
signatures or checksums for each release. Refer to Apache’s documentation for
more information.
16. Create and change the owner for /usr/share/tomcat8.5 and move Tomcat to the
following location. Add user and group to the system:
$ sudo mkdir -p /usr/share/tomcat8.5
$ sudo mv apache-tomcat-8.5.xx /usr/share/tomcat8.5/8.5.xx
$ sudo addgroup --system tomcat8.5 --quiet -force-badname
$ sudo adduser --system --home /usr/share/tomcat8.5/ --no-create-home --ingroup tomcat8.
$ sudo chown -R tomcat8.5:tomcat8.5 /usr/share/tomcat8.5
19. Change owner and access permissions of bin/, lib/, and webapps/:
$ sudo chown -Rh tomcat8.5:tomcat8.5 bin/ lib/ webapps/
$ sudo chmod 775 bin/ lib/ webapps/
https://support.ptc.com/help/thingworx_hc/thingworx_8_hc/en/index.html#page/ThingWorx/Help/Installation/Installation/install_java_and_apache_tomcat__ub… 2/6
12/24/21, 3:55 PM Install Java and Apache Tomcat (Ubuntu)
For security reasons, it is critical that you disable the AJP connector, if not already
done so by default, by performing the following step.
26. In the location of the Tomcat installation, open conf/server.xml and search for the
following line. If found, comment it out and save the file:
<Connector port ="8009" protocol="AJP/1.3" redirectPort="8443"/>
If you receive an error that the directory doesn’t exist, use the following commands to
ensure port 443 works:
sudo touch /etc/authbind/byport/443
sudo chmod 700 /etc/authbind/byport/443
sudo chown tomcat8.5:tomcat8.5 /etc/authbind/byport/443
Change the <uid> to the number that was returned in the previous step.
CATALINA_HOME=/usr/share/tomcat8.5/8.5.xx
case $1 in
start)
/bin/su -p -s /bin/sh tomcat8.5 $CATALINA_HOME/bin/startup.sh
;;
stop)
/bin/su -p -s /bin/sh tomcat8.5 $CATALINA_HOME/bin/shutdown.sh
;;
restart)
/bin/su -p -s /bin/sh tomcat8.5 $CATALINA_HOME/bin/shutdown.sh
/bin/su -p -s /bin/sh tomcat8.5 $CATALINA_HOME/bin/startup.sh
;;
esac
exit 0
https://support.ptc.com/help/thingworx_hc/thingworx_8_hc/en/index.html#page/ThingWorx/Help/Installation/Installation/install_java_and_apache_tomcat__ub… 4/6
12/24/21, 3:55 PM Install Java and Apache Tomcat (Ubuntu)
In the example below, set values for -Xms and -Xmx to 75% of the available
OS memory (for example, 12GB for a 16GB RAM system). Refer to JVM Tuning
for additional information.
[Unit]
Description=Apache Tomcat Web Application Container
After=network.target
[Service]
Type=forking
PIDFile=/var/run/tomcat.pid
Environment=CATALINA_PID=/var/run/tomcat.pid
Environment=JAVA_HOME=/usr/lib/jvm/jdk1.8.0_xxx
Environment=CATALINA_HOME=/usr/share/tomcat8.5/8.5.xx
Environment=CATALINA_BASE=/usr/share/tomcat8.5/8.5.xx
Environment=CATALINA_OPTS=
ExecStart=/usr/share/tomcat8.5/8.5.xx/bin/jsvc \
-Dcatalina.home=${CATALINA_HOME} \
-Dcatalina.base=${CATALINA_BASE} \
-Djava.awt.headless=true -Djava.net.preferIPv4Stack=tr
-XX:+UseG1GC -Dfile.encoding=UTF-8 \
-Djava.library.path=${CATALINA_BASE}/webapps/Thingworx/
-Xms=<75% of available OS memory> \
-Xmx=<75% of available OS memory> \
-cp ${CATALINA_HOME}/bin/commons-daemon.jar:${CATALINA_
-user tomcat8.5 \
-java-home ${JAVA_HOME} \
-pidfile /var/run/tomcat.pid \
-errfile ${CATALINA_HOME}/logs/catalina.out \
-outfile ${CATALINA_HOME}/logs/catalina.out \
$CATALINA_OPTS \
org.apache.catalina.startup.Bootstrap
[Install]
WantedBy=multi-user.target
b. If the Tomcat service doesn't automatically start after reboot and you receive following
error, on executing sudo systemctl enable tomcat8.5.service:
update-rc.d: error: tomcatx.x Default-Start contains no runlevels, aborting.
Then the following step is required:
Remove the tomcat8.5 file located at /etc/init.d and rerun following command:
sudo systemctl enable tomcat8.5.service
41. Create a new file in the tomcat /bin file named setenv.sh:
cd $CATALINA_HOME/bin
sudo touch setenv.sh
sudo vi setenv.sh
CATALINA_OPTS="$CATALINA_OPTS -Djava.library.path=/usr/share/tomcat8.5/8.5.xx/webapps/Th
https://support.ptc.com/help/thingworx_hc/thingworx_8_hc/en/index.html#page/ThingWorx/Help/Installation/Installation/install_java_and_apache_tomcat__ub… 5/6
12/24/21, 3:55 PM Install Java and Apache Tomcat (Ubuntu)
https://support.ptc.com/help/thingworx_hc/thingworx_8_hc/en/index.html#page/ThingWorx/Help/Installation/Installation/install_java_and_apache_tomcat__ub… 6/6