1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to configure multiple tomcat instances.

Discussion in 'Tomcat' started by sbagmeijer, Dec 8, 2015.

Thread Status:
Not open for further replies.
  1. sbagmeijer

    sbagmeijer Machine

    I had the need to run multiple tomcat instances on the same server, so I decided to make a package to get this to work with ulyaoth-tomcat packages.

    I used various on-line resources to make this works and for systemd systems I used the Fedora 23 way and created a bash script to make thing more easy and automated.

    How to install?:
    Simply install the Ulyaoth repository and then the package: ulyaoth-tomcat-multi

    How to create multiple tomcat instances?
    To create a instance:
    tomcat-multi -o create -n ulyaoth
    To create a instance that will run as a specific user:
    tomcat-multi -o create -n ulyaoth -u sbagmeijer
    To explain the command the "-o" is options you can choose "create" or "remove" and the "-n" is the name of the instance in my case "ulyaoth", if you used "-u" this will be the user tomcat will run under so I choose the user "sbagmeijer" in my example above.

    The "-u" option is not required by default it will create so Tomcat runs as the user tomcat.

    If you did run the above you can start your instance as following:
    systemd: systemctl start tomcat@ulyaoth.service
    init.d: /etc/init.d/tomcat-ulyaoth start
    Remove a instance:
    tomcat-multi -o remove -n ulyaoth
    Pretty easy right?, now please be aware that the script "tomcat-multi" can use improvements I am by far a bash expert so hopefully with time it will get better.

    Be aware that you of course must change the ports in "/var/lib/tomcats/(instance name)/conf/" as you can only use every port once.

    Hopefully we can add a "-p" option in the future to specify a port the instance should run under.

    Also the script is limited as in that it simply copies "/opt/tomcat/conf" to your instance so if you broke your default instance or changed it hugely it will be the same for your instance.

    Script commands:
    -h Shows this help information
    -o Option (.i.e create, remove)
    -n name of the new tomcat instance (.i.e ulyaoth)
    -u optional: user that will run tomcat (.i.e ulyaoth) (default is tomcat)
    If you have any improvements for the script or know how to do things better please provide it on our github we will be very grateful.
    Last edited: Dec 13, 2015
Thread Status:
Not open for further replies.

Share This Page