Install Servlet
Time to install Apache Tomcat. We will install version 9.
Inside /opt folder, download Apache Tomcat 9
cd /opt
wget https://downloads.apache.org/tomcat/tomcat-9/v9.0.64/bin/apache-tomcat-9.0.64.tar.gz
tar xzvf apache-tomcat-9.0.64.tar.gz
Rename the apache-tomcat-9.0.64 folder to tomcat.
mv apache-tomcat-9.0.64.tar.gz tomcat
Open the /etc/profile file.
nano /etc/profile
Add configuration environment variables for Java at the very bottom line and save.
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export CATALINA_HOME=/opt/tomcat
Copy dspace webapps to tomcat webapps.
cp -r /dspace/webapps/* /opt/tomcat/webapps
Create a bash script so that Tomcat can run automatically.
nano /etc/init.d/tomcat
Enter the following bash script.
#!/bin/bash
### BEGIN INIT INFO
# Provides: tomcat9
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/Stop Tomcat server
### END INIT INFO
PATH=/sbin:/bin:/usr/sbin:/usr/bin
start() {
sh /opt/tomcat/bin/startup.sh
}
stop() {
sh /opt/tomcat/bin/shutdown.sh
}
case $1 in
start|stop) $1;;
restart) stop; start;;
*) echo "Run as $0 <start|stop|restart>"; exit 1;;
esac
Give executable permissions and set it as a service.
chmod +x /etc/init.d/tomcat
update-rc.d tomcat defaults
Run Tomcat server and check the status.
service tomcat start
service tomcat status
No Comments