Deploy your Bitnami Tomcat Stack on 1&1 Cloud Platform now! Launch Now

Bitnami Tomcat for 1&1 Cloud Platform

Description

Tomcat is a widely adopted open source Java application and web server. Created by the Apache Software Foundation, it is lightweight and agile with a large ecosystem of add-ons.

First steps with the Bitnami Tomcat Stack

Welcome to your new Bitnami application running on 1&1 Cloud Platform! Here are a few questions (and answers!) you might need when first starting with your application.

What credentials do I need?

You need two sets of credentials:

  • The application credentials that allow you to log in to your new Bitnami application. These credentials consist of a username and password.
  • The server credentials that allow you to log in to your 1&1 Cloud Platform server using an SSH client and execute commands on the server using the command line. These credentials consist of an SSH username and key.

What is the administrator username set for me to log in to the application for the first time?

Username: manager

What SSH username should I use for secure shell access to my application?

SSH username: root

How to start or stop the services?

Each Bitnami stack includes a control script that lets you easily stop, start and restart services. The script is located at /opt/bitnami/ctlscript.sh. Call it without any service name arguments to start all services:

$ sudo /opt/bitnami/ctlscript.sh start

Or use it to restart a single service, such as Apache only, by passing the service name as argument:

$ sudo /opt/bitnami/ctlscript.sh restart apache

Use this script to stop all services:

$ sudo /opt/bitnami/ctlscript.sh stop

Restart the services by running the script without any arguments:

$ sudo /opt/bitnami/ctlscript.sh restart

Obtain a list of available services and operations by running the script without any arguments:

$ sudo /opt/bitnami/ctlscript.sh

What are the default ports?

A port is an endpoint of communication in an operating system that identifies a specific process or a type of service. Bitnami stacks include several services or servers that require a port.

IMPORTANT: Making this application's network ports public is a significant security risk. You are strongly advised to only allow access to those ports from trusted networks. If, for development purposes, you need to access from outside of a trusted network, please do not allow access to those ports via a public IP address. Instead, use a secure channel such as a VPN or an SSH tunnel. Follow these instructions to remotely connect safely and reliably.

Port 22 is the default port for SSH connections.

Bitnami opens some ports for the main servers. These are the ports opened by default: 80, 443.

How can I get started with Tomcat?

To get started, we suggest the following steps:

Step 1: Publish Web pages

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

Step 2: Access the management console

Use the Tomcat management console to manage the Tomcat server and deploy applications. To access it, refer to these instructions.

Step 3: Use Apache with Tomcat

You can connect the Apache Web server with Tomcat through the AJP protocol. To make them work together, enable the mod_proxy.so and mod_proxy_ajp.so modules in /opt/bitnami/apache2/conf/httpd.conf and then configure the ProxyPass directive .

For more information, refer to these instructions.

How to access the Tomcat server console?

Access the Tomcat console by browsing to http://SERVER-IP/.

How to upload files to the server with SFTP?

NOTE: Bitnami applications can be found in /opt/bitnami/apps.
  • If you are using the Bitnami Launchpad for 1&1 Cloud Platform, obtain your SSH credentials by following these steps:

    • Browse to the Bitnami Launchpad for 1&1 and sign in if required using your Bitnami account.
    • Select the "Virtual Machines" menu item.
    • Select your cloud server from the resulting list.
    • Note the server IP address and SSH credentials on the resulting page.

      SSH credentials

  • If you are using the 1&1 Control Panel, obtain your SSH credentials by following these steps:

    • Log in to the 1&1 Control Panel.
    • Navigate to the "Infrastructure -> Servers" section.
    • Look through the list of servers until you find the server you wish to modify. Click the server name.
    • In the "Features -> Server access" section, note the SSH username and click the "Show Password" link to obtain the corresponding SSH password.

      SSH credentials

Although you can use any SFTP/SCP client to transfer files to your server, this guide documents FileZilla (Windows, Linux and Mac OS X), WinSCP (Windows) and Cyberduck (Mac OS X).

Using a Password

Once you have your server's SSH credentials, choose your preferred application and follow the steps below to connect to the server using SFTP.

FileZilla

Follow these steps:

  • Download and install FileZilla.
  • Launch FileZilla and use the "File -> Site Manager -> New Site" command to bring up the FileZilla Site Manager, where you can set up a connection to your server.
  • Enter your server host name.
  • Select "SFTP" as the protocol and "Ask for password" as the logon type. Specify root as the user name and enter the server password.

    FileZilla configuration

  • Use the "Connect" button to connect to the server and begin an SFTP session. You might need to accept the server key, by clicking "Yes" or "OK" to proceed.

You should now be logged into the /root directory on the server. You can now transfer files by dragging and dropping them from the local server window to the remote server window.

If you have problems accessing your server, get extra information by use the "Edit -> Settings -> Debug" menu to activate FileZilla's debug log.

FileZilla debug log

WinSCP

Follow these steps:

  • Download and install WinSCP.
  • Launch WinSCP and in the "Session" panel, select "SCP" as the file protocol.
  • Enter your server host name and specify root as the user name. Enter the corresponding password as well.

    WinSCP configuration

  • From the "Session" panel, use the "Login" button to connect to the server and begin an SCP session.

You should now be logged into the /root directory on the server. You can now transfer files by dragging and dropping them from the local server window to the remote server window.

Cyberduck

Follow these steps:

  • Select the "Open Connection" command and specify "SFTP" as the connection protocol.

    Cyberduck configuration

  • In the connection details panel, enter the server IP address, the username root and the SSH password.

    Cyberduck configuration

  • Use the "Connect" button to connect to the server and begin an SFTP session.

You should now be logged into the /root directory on the server. You can now transfer files by dragging and dropping them from the local server window to the remote server window.

How to find the MySQL database credentials?

How to connect to the MySQL database?

You can connect to the MySQL database from the same computer where it is installed with the mysql client tool.

$ mysql -u root -p

You will be prompted to enter the root user password. This is the same as the application password.

How to connect to Tomcat from a different machine?

For security reasons, Tomcat Manager and Tomcat Host Manager cannot be accessed over a public IP address. Both applications only work from localhost by default but you can allow remote connections by changing their configuration.

IMPORTANT: Make these applications accessible a public IP address is a significat security risk. Instead, use a secure channel such as a VPN or an SSH tunnel. Follow these instructions to remotely connect safely and reliably.

Connecting to Tomcat Manager from a different machine

In order to allow remote connections to the Tomcat Manager, follow the instructions below:

  • Create a file named /opt/bitnami/apache-tomcat/conf/Catalina/localhost/manager.xml with the following content:

    <Context privileged="true" antiResourceLocking="false" 
             docBase="${catalina.home}/webapps/manager">
        <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="^.*$" />
    </Context>
    
  • Restart Tomcat:

    $ sudo /opt/bitnami/ctlscript.sh restart tomcat
    

Connecting to Tomcat Host Manager from a different machine

In order to allow remote connections to the Tomcat Host Manager, follow the instructions below:

  • Create a file named /opt/bitnami/apache-tomcat/conf/Catalina/localhost/host-manager.xml with the following content:

    <Context privileged="true" antiResourceLocking="false"
             docBase="${catalina.home}/webapps/host-manager">
        <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="^.*$" />
    </Context>
    
  • Restart Tomcat:

    $ sudo /opt/bitnami/ctlscript.sh restart tomcat
    

How to access phpMyAdmin?

For security reasons, phpMyAdmin is accessible only when using 127.0.0.1 as the hostname. To access it from a remote system, you must create an SSH tunnel that routes requests to the Web server from 127.0.0.1. This implies that you must be able to connect to your server over SSH in order to access these applications remotely.

IMPORTANT: Before following the steps below, ensure that your Web and database servers are running.
NOTE: The steps below suggest using port 8888 for the SSH tunnel. If this port is already in use by another application on your local machine, replace it with any other port number greater than 1024 and modify the steps below accordingly. Similarly, if you have enabled Varnish, your stack's Web server might be running on port 81. In this case, modify the steps below to use port 81 instead of port 80 for the tunnel endpoint.

Accessing phpMyAdmin on Windows

Watch the following video to learn how to easily access phpMyAdmin on Windows through an SSH tunnel:

TIP: Refer to these instructions to learn how to obtain your private key.

In order to access phpMyAdmin via SSH tunnel you need an SSH client. In the instructions below we have selected PuTTY, a free SSH client for Windows and UNIX platforms. The first step is having PuTTY configured. Please, check how to configure it in the section how to connect to the server through SSH using an SSH client on Windows.

Once you have your SSH client correctly configured and you tested that you can successfully access to your instance via SSH, you need to create an SSH tunnel in order to access phpMyAdmin. For doing so, follow these steps:

  • In the "Connection -> SSH -> Tunnels" section, add a new forwarded port by introducing the following values:

    • Source port: 8888
    • Destination: localhost:80

    This will create a secure tunnel by forwarding a port (the "destination port") on the remote server to a port (the "source port") on the local host (127.0.0.1 or localhost).

  • Click the "Add" button to add the secure tunnel configuration to the session. (You'll see the added port in the list of "Forwarded ports").

    PuTTY configuration

  • In the "Session" section, save your changes by clicking the "Save" button.
  • Click the "Open" button to open an SSH session to the server. The SSH session will now include a secure SSH tunnel between the two specified ports.
  • Access the phpMyAdmin console through the secure SSH tunnel you created, by browsing to http://127.0.0.1:8888/phpmyadmin.
  • Log in to phpMyAdmin by using the following credentials:

    • Username: root
    • Password: application password. (Refer to our FAQ to learn how to find your application credentials).

Here is an example of what you should see:

Access phpMyAdmin

If you are unable to access phpMyAdmin, verify that the SSH tunnel was created by checking the PuTTY event log (accessible via the "Event Log" menu):

PuTTY configuration

Accessing phpMyAdmin on Linux and Mac OS X

To access the application using your Web browser, create an SSH tunnel, as described below.

  • Open a new terminal window on your local system (for example, using "Finder -> Applications -> Utilities -> Terminal" in Mac OS X or the Dash in Ubuntu).
  • Run the following command, remembering to replace SERVER-IP with the public IP address or hostname of your server. Enter your SSH password when prompted.

       $ ssh -N -L 8888:127.0.0.1:80 bitnami@SERVER-IP
    
NOTE: If successful, the above command will create an SSH tunnel but will not display any output on the server console.
  • Access the phpMyAdmin console through the secure SSH tunnel you created, by browsing to http://127.0.0.1:8888/phpmyadmin.
  • Log in to phpMyAdmin by using the following credentials:

    • Username: root
    • Password: application password. (Refer to our FAQ to learn how to find your application credentials).

Here is an example of what you should see:

Access phpMyAdmin

How to reset the MariaDB root password?

Please note that depending on the version you have installed, you may find the MariaDB files at /opt/bitnami/mysql

If you don't remember your MariaDB root password, you can follow the steps below to reset it to a new value:

  • Create a file in /home/bitnami/mysql-init with the content shown below (replace NEW_PASSWORD with the password you wish to use):

     UPDATE mysql.user SET Password=PASSWORD('NEW_PASSWORD') WHERE User='root';
     FLUSH PRIVILEGES;
    
  • Stop the MariaDB server:

     $ sudo /opt/bitnami/ctlscript.sh stop mariadb
    
  • Start MariaDB with the following command:

     $ sudo /opt/bitnami/mariadb/bin/mysqld_safe --defaults-file=/opt/bitnami/mariadb/my.cnf --pid-file=/opt/bitnami/mariadb/data/mysqld.pid --init-file=/home/bitnami/mysql-init 2> /dev/null &
    
  • Restart the MariaDB server:

     $ sudo /opt/bitnami/ctlscript.sh restart mariadb
    
  • Remove the init script

     $ rm /home/bitnami/mysql-init
    

How to change the MariaDB root password?

You can modify the MariaDB password using the following command at the shell prompt:

$ /opt/bitnami/mariadb/bin/mysqladmin -p -u root password NEW_PASSWORD

How to create an SSL certificate for Apache Tomcat?

A detailed guide is available in the official Apache Tomcat documentation at http://tomcat.apache.org/tomcat-6.0-doc/ssl-howto.html.

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"
                  keystoreFile="conf/myKeystore"
                  keystorePass="your_password"
                  SSLCertificateFile="/opt/bitnami/apache-tomcat/conf/ssl/tomcat.cert.pem"
                  SSLCertificateKeyFile="/opt/bitnami/apache-tomcat/conf/ssl/tomcat.key.pem"/>
    
  • 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 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 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 mod_proxy.so and mod_proxy_ajp.so modules in /opt/bitnami/apache2/conf/httpd.conf. Then, add the following lines to the file:

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

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 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 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/setenv.sh 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 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).

<max-file-size>83886080</max-file-size>
<max-request-size>83886080</max-request-size>

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

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

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

$ sudo /opt/bitnami/ctlscript.sh restart tomcat

How can I run a command in the Bitnami Tomcat Stack?

Log in to the server console as the bitnami user and run the command as usual. The required environment is automatically loaded for the bitnami user.

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
    </Location>
    
    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 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 create a full backup of Tomcat?

Backup

The Bitnami Tomcat Stack is self-contained and the simplest option for performing a backup is to copy or compress the Bitnami stack installation directory. To do so in a safe manner, you will need to stop all servers, so this method may not be appropriate if you have people accessing the application continuously.

Follow these steps:

  • Change to the directory in which you wish to save your backup:

      $ cd /your/directory
    
  • Stop all servers:

      $ sudo /opt/bitnami/ctlscript.sh stop
    
  • Create a compressed file with the stack contents:

      $ sudo tar -pczvf application-backup.tar.gz /opt/bitnami
    
  • Restart all servers:

      $ sudo /opt/bitnami/ctlscript.sh start
    

You should now download or transfer the application-backup.tar.gz file to a safe location.

Restore

Follow these steps:

  • Change to the directory containing your backup:

      $ cd /your/directory
    
  • Stop all servers:

      $ sudo /opt/bitnami/ctlscript.sh stop
    
  • Move the current stack to a different location:

      $ sudo mv /opt/bitnami /tmp/bitnami-backup
    
  • Uncompress the backup file to the original directoryv

      $ sudo tar -pxzvf application-backup.tar.gz -C /
    
  • Start all servers:

      $ sudo /opt/bitnami/ctlscript.sh start
    

If you want to create only a database backup, refer to these instructions for MySQL and PostgreSQL.

How to debug errors in your database?

The main log file is created at /opt/bitnami/mysql/data/mysqld.log on the MySQL database server host.

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.

oneone

Bitnami Documentation