Tomcat7 User – Run Tomcat7 as tomcat7 or Any Other User

tomcat7

What will be the recommended way to ensure that a Tomcat7 instance is running as the tomcat7 (or any other) user?

I suppose that I can modify tomcat7-instance/bin/startup.sh and tomcat7-instance/bin/shutdown.sh and add 'su tomcat7' at the top.

In Tomcat6 I think it was the environment variable TOMCAT6_USER.

Best Answer

The most common way is to install the standard tomcat7 package with apt-get and to start it using:

sudo service tomcat7 start

The default user and group are configured in /etc/default/tomcat7 as you can see in this excerpt:

# Run Tomcat as this user ID. Not setting this or leaving it blank will use the
# default of tomcat7.
TOMCAT7_USER=tomcat7

# Run Tomcat as this group ID. Not setting this or leaving it blank will use
# the default of tomcat7.
TOMCAT7_GROUP=tomcat7