Apache Tomcat
- is an open-source implementation of the Java Servlet, JavaServer Pages, Java Expression Language and WebSocket technologies
- provides a “pure Java” HTTP web server environment in which Java code can run
Installation
manual
- go into ApacheTomcat site and download package
- un-package package
export CATALINA_HOME=/path/to/un-package- put .war packages into /webapps directory
- start server:
./bin/startup.sh- stop server:
./bin/shutdown.sh
homebrew
Install tomcat using homebrew
brew install tomcatThis would download tomcat into
/usr/local/CellardirectoryVerify if tomcat was installed
brew list
apt-get
https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-8-on-ubuntu-16-04
Update apt-get package index
sudo apt-get updateInstall Java Development Kit
sudo apt-get install default-jdkhttps://www.mkyong.com/tomcat/how-to-install-tomcat-in-ubuntu/
Search tomcat packages
sudo apt-cache search tomcatInstall tomcat packages
sudo apt-get install tomcat8-admin sudo apt-get install tomcat8
Configuration
general
deploy
- Obtain WAR package, via maven execute:
mvn clean package- then go into
./targetfolder and copy the.warpackage- paste
.warpackage into/path/to/tomcat/libexec/webappsdirectory- restart tomcat server
- this would extract the .war package into the same directory
- go to
http://ocalhost:8080/name-of-directorymanage webapps
- to add an manage applications running on the server edit configuration file
vim /path/to/tomcat/libexec/conf/tomcat-users.xml- Towards the bottom of this short config file you will see a selection of users – all commented out by default. You need to uncomment one of these and give it the extra role “manager-gui” (preferably also changing the username and password for security). The resultant user entry should look something like this:
<user username=“admin” password=“password” roles=“tomcat,manager-gui” />- restart tomcat server
- After this you can navigate to the page (or click the “Manager App” link on the main Tomcat Server page):
- generate secure key
keytool -genkey -alias keynamehere -keyalg RSA -keystore /path/to/new/keystore- add this to the $(CATALINA_BASE)/conf/server.xml file
1.
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol" maxThreads="150" SSLEnabled="true" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" keystoreFile=“/path/to/new/keystore” keystorePass="123456"/>- restart tomcat server
- go to https://localhost:8443
apt-get
- configuration and logs are created in
/var/lib/tomcat7- Tomcat bin folder is created in
/usr/share/tomcat7
Commands
homebrew
brew services start tomcat brew services stop tomcat brew services restart tomcat
manual/direct way
Run tomcat
/path/to/tomcat/bin/catalina run
- navigate to host page at: http://localhost:8080/
OR PREFERRED WAY run tomcat
/path/to/tomcat/libexec/bin/startup.shStop tomcat
/path/to/tomcat/libexec/bin/shutdown.shDeployed applications are usually then located under the directory
/path/to/tomcat/libexec/webapps/
unix service managers
refer to: Daemon Manager - (SystemV - Upstart - Systemd - Launchd)
sample commands for apt-get:
sudo /etc/init.d/tomcat8 startsudo /etc/init.d/tomcat8 stopsudo /etc/init.d/tomcat8 restart