On 9/5/2024 8:40 AM, David Rush wrote:
Darryl:

Do you have a script or something that copies the "needed files" from the
previous version to the new version?

Seems like you would need to copy all your webapps and any customizations
in your config files (I sometimes tweak my server.xml and
logging.properties).

David

I tend to set up my Tomcat environments like the following:

/home/tcadmin/Apache/apache-tomcat-9.0.xx
This is the unaltered unpacking of that tar.gz file from tomcat.apache..org

/home/tcadmin/Platforms/serviceName/9.0.xx
This is the location for a particular service's files that are different than the stock Tomcat. Things such as altered server.xml, tomcat-users.xml, and Tomcat-wide library files go here.

/home/tcadmin/Platforms/serviceName/vhhosts/hostName/webapps
This is the location of a serviceName's virtual host web application directory. A particular service can host multiple virtual hosts, so each potential virtual host gets its own webapps directory.

To create a service, I use the following structure:

/home/tcadmin/Services/serviceName/CATALINA_HOME
/home/tcadmin/Services/serviceName/CATALINA_BASE

Link CATALINA_HOME to the appropriate /home/tcadmin/Apache/apache-tomcat-9.0.xx directory.

Link CATALINA_BASE to the appropriate /home/tcadmin/Platforms/serviceName/9.0.xx directory.

server.xml contains a Host node with:

appBase="/home/tcadmin/Platforms/serviceName/vhost/hostName/webapps"

Now to update, all you do is:

1. Unpack a new version of Tomcat in /home/tcadmin/Apache/apache-tomcat-9.0.xx
2. Create a new directory i/home/tcadmin/Platforms/serviceName/9.0.xx
3. Copy appropriate files into /home/tcadmin/Platforms/serviceName/9.0.xx
4. Edit the copied files to match the current configuration

Note that the above 4 steps can be done while the environment is running. They can also be automated with scripts.

To update, do the following:

1. Shut down the existing Tomcat service
2. Delete the links in /home/tcadmin/Services/serviceName
3. Make new links to the new places created above
4. Start service

Check either /home/tcadmin/Services/serviceName/CATALINA_BASE/logs or
/home/tcadmin/Platforms/serviceName/9.0.xx/logs for issues.

Oh, and on Ubuntu, the following works so that you can create multiple Tomcat services:

Environment=CATALINA_HOME=/home/tcadmin/Services/%i/CATALINA_HOME/
Environment=CATALINA_BASE=/home/tcadmin/Services/%i/CATALINA_BASE/
Environment=CATALINA_PID=/var/run/tomcat/%i.pid

Then you can create a template systemd file with a name like tomcat-@.service. When you enable the service, use tomcat-serviceName.service. That way you can have multiple Tomcat services on one platform.

You'll also need to create /var/run/tomcat at boot, since the /var/run filesystem is ephemeral. Something like the following should work:

[Unit]
Description=Create Tomcat PID directory

[Service]
Type=oneshot
RuntimeDirectory=tomcat
User=tcadmin
Group=tcadmin
ExecStart=/bin/true
RemainAfterExit=true

[Install]
WantedBy=multi-user.target

Finally, if you use the Manager application, you'll need to create a manager.xml file in every Platform/serviceName/9.0.xx/conf/Catalina/hostName

Change version numbers (9.0.xx) to suit your environment.

The service account (tcadmin) is an unprivileged user account that cannot be logged into remotely. You muse log into the remote system, then su to that account. I suppose that I could protect it via sudo so that sudo -i -u tcadmin would work.

I think that's about it.

. . . just my two cents
/mde/


On Thu, Sep 5, 2024 at 9:29 AM Darryl Baker <darryl.ba...@northwestern.edu>
wrote:

My method for updating Tomcat is that it lives behind a symbolic link.
/opt/tomcat/latest points to the version I want to run.
/opt/tomcat/apache-tomcat-9.0.XX when I want to upgrade I untar the latest
version, stop the running version, copy over the needed files to the new
version, repoint the link, and start up the new version. The system control
file use the symbolic link so needs no changes.

Darryl Baker, GSEC, GCLD (he/him/his)
Sr. System Administrator
Distributed Application Platform Services
Northwestern University
4th Floor
2020 Ridge Avenue
Evanston, IL 60208-0801
darryl.ba...@northwestern.edu <mailto:darryl.ba...@northwestern.edu>
(847) 467-6674 <tel:+18474676674>




On 9/5/24, 9:56 AM, "David Rush" <david.r...@wyo.gov <mailto:
david.r...@wyo.gov>> wrote:


Sebastian:


I want to keep HOME and BASE separate so that when a new version of Tomcat
comes out it's easy to swap the new binary download in at CATALINA_HOME
without impacting my configuration or webapps in CATALINA_BASE


David


On Thu, Sep 5, 2024 at 8:52 AM Sebastian Trost
<m...@sebastiantrost.de.inva <mailto:m...@sebastiantrost.de.inva>lid>
wrote:


David,

On 05.09.2024 16:13, David Rush wrote:
My CATALINA_HOME is /opt/tomcat9/home (which is a symlink to
/opt/tomcat9/apache-tomcat-9.0.93)
My CATALINA_BASE is /var/opt/tomcat9
Why are you setting the CATALINA_BASE-variable? If you're running just
one Tomcat instance, this variable is not needed. Also, you point this
variable to a different directory?

See


https://urldefense.com/v3/__https://tomcat.apache.org/tomcat-10.1-doc/introduction.html
<
https://urldefense.com/v3/__https://tomcat.apache.org/tomcat-10.1-doc/introduction.html>*CATALINA_HOME_and_CATALINA_BASE__;Iw!!Dq0X2DkFhyF93HkjWTBQKhk!Rc7C8HkZWIbxfAm38rp_i-EV1fH7v3D-qSOqznnMXuPLPia3Lv6Ln8BmtPmJv0LMLNRTToWFeSGEIMSE9xhvPZvlufqjKXI$


Sebastian

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to