Apache Tomcat

    How to start/stop the Apache Tomcat server?

    You can use the "ctlscript.sh" utility which is in the installation directory.

    linux_platform.png On Linux:

    $ ./ctlscript.sh start tomcat
    

    win_platform.png On Windows: Start -> BitNami application Stack -> Services -> Start servers

    You can also open the Windows Services panel and check the "applicationTomcat" service.

    mac_platform.png On OS X: There is a "control" graphical tool in the installation directory or you can use the "ctlscript.sh" utility from a Terminal.

    host:~ user$ cd /Applications/application-version
    host:~ user$ ./ctlscript.sh start tomcat

    You get more info about this at Native_Installers_Quick_Start_Guide#How_can_start_or_stop_the_servers.3f


    If you find the following error you should delete the catalina.pid file and start the server again.

    PID file (installdir/apache-tomcat/temp/catalina.pid) found. Is Tomcat still running? Start aborted.

    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 the server.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="mysqlnetwork"
                   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 the installdir/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

    Tag page (Edit tags)
    • No tags
    Pages that link here
    Page statistics
    60746 view(s), 21 edit(s) and 8233 character(s)

    Comments

    You must login to post a comment.

    Attach file

    Attachments