Bitnami Apache Tomcat for AWS Cloud

Apache Tomcat is an open source application server which supports Java Servlets, JavaServer Pages and Java WebSockets.

How to change the Apache Tomcat port?

With the default configuration, Apache Tomcat will listen for requests on port 8080. To use a different port, edit the server.xml file and modify the value specified in the Port directive.

<Connector port="8080" URIEncoding="UTF-8" protocol="HTTP/1.1"
connectionTimeout="20000" redirectPort="8443" />

Restart the Apache Tomcat server for the changes to take effect.

How to configure the Apache Tomcat server?

The main Apache Tomcat configuration file is at /opt/bitnami/apache-tomcat/conf/server.xml.

Once Apache Tomcat starts, it will create several log files in the /opt/bitnami/apache-tomcat/logs directory. The main log file is the catalina.out file where you can find error messages.

How to change the Java memory settings?

The Java Virtual Machine (JVM) determines the default settings for your Java application:

JAVA_OPTS="-Xms256m -Xmx512m"

You can increase these Java settings for your application if necessary. The settings are in the /opt/bitnami/java/bitnami/ file. Here is an example of how to change the memory settings:

$ export JAVA_OPTS="$JAVA_OPTS -Xms256M -Xmx768M"
IMPORTANT: This file is a symlink to a configuration file that changes depending on the instance type that you are currently using. The symlink will be automatically changed when you resize your server.

How is Apache server connected with Tomcat?

Bitnami stacks include the Apache Web server. There are different ways to connect these two servers. One of them is connecting through the AJP protocol.

The AJP Connector element represents a Connector component that communicates with a web connector via the AJP protocol. This is used to invisibly integrate Tomcat into an Apache installation and have Apache handle the static content of the web application and/or to utilize Apache's SSL processing.

To make them work together, enable the and modules in /opt/bitnami/apache2/conf/httpd.conf. Then, add the following lines to the file:

<Location /APPURL>
 ProxyPass ajp://localhost:8009/APPURL

If you connect your application through AJP, you will probably want to disable the Tomcat HTTP port. The Bitnami Tomcat Stack has the HTTP server disabled by default. To modify this configuration, uncomment the HTTP section in the /opt/bitnami/apache-tomcat/conf/server.xml file.

How to create a custom Java application?

Many users run a Bitnami stack as a development environment for their own projects (as opposed to running third-party applications). To create a custom Java application from scratch, follow the steps below. These steps assume that your application will live in the /opt/bitnami/apps/myapp/ directory:

  • Run the following commands to create the directories:

    $ sudo mkdir /opt/bitnami/apps/myapp
    $ sudo mkdir /opt/bitnami/apps/myapp/conf
  • Create and edit the /opt/bitnami/apps/myapp/conf/httpd-prefix.conf file and add the line below to it:

    Include "/opt/bitnami/apps/myapp/conf/httpd-app.conf"
  • Create and edit the /opt/bitnami/apps/myapp/conf/httpd-app.conf file and add the content below to it. This is the main configuration file for your application, so modify it further depending on your application's requirements.

    <Location /myapp>
    ProxyPass ajp://localhost:8009/myapp
    NOTE: 8009 is the default port for the AJP connector. If you have customized the stack to use a different port, change it here as well.
  • Once you have created the files and directories above, add the following line to the end of the main Apache configuration file at /opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf, as shown below:

    Include "/opt/bitnami/apps/myapp/conf/httpd-prefix.conf"
  • Restart the Apache server.

You should now be able to access the application at http://SERVER-IP/myapp.

How to create an SSL certificate for Apache Tomcat?

A detailed guide is available in the official Apache Tomcat documentation at

How to debug errors in Tomcat?

The main Apache Tomcat configuration file is at /opt/bitnami/apache-tomcat/conf/server.xml.

Once Apache Tomcat starts, it will create several log files in the /opt/bitnami/apache-tomcat/logs directory. The main log file is the catalina.out file where you can find error messages. On some platforms, you may need root account privileges to view these files.

How to enable SSL access over HTTPS?

You can configure Apache Tomcat to enable SSL access to applications using HTTPS. It is necessary to configure Tomcat with the location of the Apache SSL certificate, as described below.

  • Check that the certificate file is present at /opt/bitnami/apache-tomcat/conf/ssl/tomcat.cert.pem and the certificate key file is present at /opt/bitnami/apache-tomcat/conf/ssl/tomcat.key.pem.

  • Uncomment the following line in the /opt/bitnami/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"
  • Restart the Apache Tomcat server

You should now be able to access your Web applications over HTTPS by browsing to https://SERVER-IP:8443.

How to increase the upload size limit in Tomcat?

Modify the max-file-size and max-request-size values in the application's web.xml configuration file (for example, in the webapps/manager/WEB-INF/web.xml file).


Remember to restart your Tomcat server for the changes to take effect.

How to install OracleDB client files for Apache Tomcat?

If you want your java application to be able to connect to a full featured and functional OracleDB database, please follow the steps below.

  • Stop the tomcat server:

     $ sudo /opt/bitnami/ stop tomcat
  • Download the corresponding JDBC drivers for OracleDB from the Oracle official website. Pay attention to the server version. For example, for a 11g Release 2 server, you will need OJDBC6.jar.

  • Unzip it and place it under the folder /opt/bitnami/apache-tomcat/lib/ext

  • Start the tomcat server again:

     $ sudo /opt/bitnami/ start tomcat

That was it! Your tomcat installation can now connect to Oracle databases.

How to publish a Web page?

To serve Web pages with Apache Tomcat, simply copy your files to the default document root directory at /opt/bitnami/apache-tomcat/webapps/ROOT.

How to use an independent Java installation instead of the bundled one?

Change the JAVA_HOME variable in the /opt/bitnami/apache-tomcat/bin/ file and the JRE_HOME variable in the /opt/bitnami/apache-tomcat/scripts/ to point to your custom Java installation. Then, restart the Tomcat server:

$ sudo /opt/bitnami/ restart tomcat

Bitnami Documentation