I have a VM which runs Ubuntu 16.04 and LAMP and currently is hosting some WordPress sites.

I have implemented locally a web project which runs in Tomcat server and I want to deploy it in the VM. I am planning to install Apache Tomcat 8 and then deploy the war file of my project there.

My question is :

  1. After the installation of the Tomcat 8 in the VM, should I make an extra setting? in the Apache WebServer or somewhere else?

  2. To connect my webApplication with a domain name, when setting the Virtual host in the .conf file, in the DocumentRoot I will add the path of the webapp?

.conf file:

<VirtualHost *:80>
    ServerAdmin admin@test.com
    ServerName test.com
    ServerAlias www.test.com
    DocumentRoot /opt/tomcat/webapps/webApplication
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

There are a couple of ways of doing this, either serve requests to the application using the mod_jk connector, or by configuring apache as a reverse proxy with mod_proxy and sending requests to the tomcat web server. Both will work as a subdomain or as a Directory or Alias directive, so set up will be along these lines:

This is a simple configuration for mod_jk (from https://tomcat.apache.org/connectors-doc/webserver_howto/apache.html)

 # Load mod_jk module
    LoadModule    jk_module  modules/mod_jk.so
    # Add the module (activate this lne for Apache 1.3)
    # AddModule     mod_jk.c
    # Where to find workers.properties
    JkWorkersFile /etc/httpd/conf/workers.properties
    # Where to put jk shared memory
    JkShmFile     /var/log/httpd/mod_jk.shm
    # Where to put jk logs
    JkLogFile     /var/log/httpd/mod_jk.log
    # Set the jk log level [debug/error/info]
    JkLogLevel    info
    # Send requests for context /examples to worker named worker1
    JkMount  /examples/* worker1

and this is a simple setup for a reverse proxy which can be added to a VirtualHost or a Directory (official documentation:https://tomcat.apache.org/connectors-doc/common_howto/proxy.html)

 ProxyRequests off 
 ProxyPass / http://localhost:8082/ 
 ProxyPassReverse / http://localhost:8082/ 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.