Apache Tomcat is an open-source application server for Java apps that you can install on your Opalstack account with the procedure described below.
This procedure is adapted from one posted by @anjanesh at https://community.opalstack.com/d/699-tomcat-and-jdk/3 with the following updates:
- Includes steps to install a newer version of Java
- Includes a newer version of Tomcat
- Updates the app configuration via
sed
instead of manually editing the config
Here we go:
- Go to https://my.opalstack.com/apps/ and create a new "Nginx Proxy Port" app and make a note of the new app's port assignment.
- Go to https://my.opalstack.com/domains/ and create a site to serve the app you created in step 1.
- Log in to SSH as your app's shell user and run the following commands, replacing
NAME_OF_YOUR_APP
with the name of the app you created in step 1 and NNNNN
with the app's assigned port.
mkdir ~/opt
cd ~/opt
wget https://download.oracle.com/java/21/latest/jdk-21_linux-x64_bin.tar.gz
tar zxf jdk-21_linux-x64_bin.tar.gz
ln -s jdk-21.0.5 java
export JRE_HOME=$HOME/opt/java
echo "export JRE_HOME=$JRE_HOME" >> ~/.bashrc
cd ~/apps/NAME_OF_YOUR_APP
wget https://dlcdn.apache.org/tomcat/tomcat-10/v10.1.33/bin/apache-tomcat-10.1.33.tar.gz
tar zxf apache-tomcat-10.1.33.tar.gz --strip 1
sed -i -e 's/"8080"/"NNNNN"/g' conf/server.xml
rm -rf logs
ln -s $HOME/logs/apps/NAME_OF_YOUR_APP logs
~/apps/NAME_OF_YOUR_APP/bin/startup.sh
Tomcat should now be up and running at the URL of the site that you created in step 2 above. If it doesn't seem to be working then check the Tomcat logs in the app's logs
subdirectory for possible problems and troubleshoot as appropriate.
The commands to start and stop the installed app are:
- Start:
~/apps/NAME_OF_YOUR_APP/bin/startup.sh
- Stop:
~/apps/NAME_OF_YOUR_APP/bin/shutdown.sh