Cloud Servers | Virtual Machines | Native Installers | |
Configuration file(s) | /opt/bitnami/apache-tomcat/conf/server.xml | /opt/bitnami/apache-tomcat/conf/server.xml | install_dir/apache-tomcat/conf/server.xml |
Log file(s) | /opt/bitnami/apache-tomcat/logs/* | /opt/bitnami/apache-tomcat/logs/* | install_dir/apache-tomcat/logs/* |
Default port | 8080, 8443 (SSL) | 8080, 8443 (SSL) | 8080, 8443 (SSL) |
AJP port | 8009 | 8009 | 8009 |
System user account | tomcat | tomcat | tomcat |
Service control | sudo /opt/bitnami/ctlscript.sh start|stop|restart tomcat | sudo /opt/bitnami/ctlscript.sh start|stop|restart tomcat | install_dir/ctlscript.sh start|stop|restart tomcat |
How to configure the Apache Tomcat server?
The main Apache Tomcat configuration file is called server.xml which you can find at /installdir/apache-tomcat/conf/server.xml.
Once Apache Tomcat starts, it will create several log files in the /installdir/apache-tomcat/logs directory. The main log is the “catalina.out” file where you can find any possible error. If no error is found, you will see a message similar to:
/installdir/apache-tomcat/ctl.sh : tomcat started
How to configure the Java memory settings for Tomcat?
These are the default memory settings for Java:
JAVA_OPTS="-XX:MaxPermSize=512m -Xms256m -Xmx512m"
You can increase these Java settings for you application if it is necessary. You can find them in the /installdir/apache-tomcat/bin/setenv.sh file for native installers for Linux and OS X. For Cloud Images you can find the Java memory settings in the/opt/bitnami/java/bitnami/setenv.sh.
export JAVA_OPTS="-XX:MaxPermSize=256M -Xms256M -Xmx768M $JAVA_OPTS"
IMPORTANT: This file is a symlink to a “micro-setenv.sh”, “small-setenv.sh”… depending on the instance type that you are currently using. The symlink will be automtically changed when you resize your server.
For Windows you should modify the /installdir/apache-tomcat/bin/setenv.bat and reinstall the services.
> cd installdir > serviceinstall.bat UNINSTALL > serviceinstall.bat INSTALL
How to change the Apache Tomcat port?
With the default configuration, Apache Tomcat will wait for requests in the port 8080. You can change that by editing theserver.xml file and modifiying the value specified in the Port directive. On Linux and OS X platforms you should install the Stack as root user to select a port number under 1024.
<Connector port="8080" URIEncoding="UTF-8" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
Then it is necessary to restart the Apache Tomcat server.
How to publish my web page?
If you already have a web page and you want to serve its content with Apache Tomcat, you can do so simply by copying your files to the default document root directory: /installdir/apache-tomcat/webapps/ROOT.
For further details check How to deploy Java Applications in Tomcat
How to enable SSL to access through https?
You can configure Apache Tomcat to enable SSL connections for accessing to the application using the HTTPS protocol. It is necessary to specify the Apache SSL certificate. If you do not have the cert you can create following these steps in the section below.
Check that you have the certificate file at “/installdir/apache-tomcat/conf/ssl/tomcat.cert.pem” and the certificate key file at “/installdir/apache-tomcat/conf/ssl/tomcat.key.pem”.
To enable SSL you should uncomment the following line in the /installdir/apache-tomcat/conf/server.xml file:
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" disableUploadTimeout="true" acceptCount="100" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" keystoreFile="conf/myKeystore" keystorePass="your_password" SSLCertificateFile="installdir/apache-tomcat/conf/ssl/tomcat.cert.pem" SSLCertificateKeyFile="installdir/apache-tomcat/conf/ssl/tomcat.key.pem"/>
Then restart the Apache server and try to access at “https://localhost:8443“.
How to create a SSL certificate for Apache Tomcat?
You can find a detailed guide in the official Apache Tomcat documentation at http://tomcat.apache.org/tomcat-6.0-doc/ssl-howto.html
How to connect Apache server with Tomcat?
Some Stacks like Tomcat Stack or JBoss Stack ships Apache server. There are different ways to connect these two servers. One of this is connecting through AJP protocol.
The AJP Connector element represents a Connector component that communicates with a web connector via the AJP
protocol. This is used for cases where you wish to invisibly integrate Tomcat into an Apache installation, and you want Apache to handle the static content contained in the web application, and/or utilize Apache’s SSL processing.
You should to enable the “mod_proxy.so” and “mod_proxy_ajp.so” modules in “installdir/apache2/conf/httpd.conf” and add the following lines in the same file:
<Location /your_application_url> ProxyPass ajp://localhost:8009/your_application_url </Location>
If you connect your application through AJP, you probably want to disable the Tomcat HTTP port. Tomcat and JBoss Stacks have the HTTP server disabled by default. If you want to modify this configuration you can uncomment the HTTP section in theinstalldir/apache-tomcat/conf/server.xml file.
How to increase the upload size limit in Tomcat?
You just need to modify the <max-file-size> and <max-request-size> values in the web.xml configuration file (/installdir/apache-tomcat/webapps/manager/WEB-INF/web.xml).
<max-file-size>83886080</max-file-size> <max-request-size>83886080</max-request-size>
Then restart your Tomcat server