1

How to change the user tomcat runs, to www-data?

I tried the same thing as How to run tomcat6 on ubuntu as root? but it doesnt cause any changes.

2
  • how did you install tomcat?
    – Mike
    Jun 28, 2012 at 12:28
  • apt-get install tomcat6 Jun 28, 2012 at 12:29

1 Answer 1

3

Here is how I just did it with tomcat6 installed..

I first stopped tomcat from running

/etc/init.d/tomcat6 stop

Changed the following in

/etc/default/tomcat6

To be the following

# Run Tomcat as this user ID. Not setting this or leaving it blank will use the
# default of tomcat6.
TOMCAT6_USER=www-data

# Run Tomcat as this group ID. Not setting this or leaving it blank will use
# the default of tomcat6.
TOMCAT6_GROUP=www-data

Then I had to change ownership of the log directory

chown -R www-data: /var/log/tomcat6
chown -R www-data: /usr/lib/tomcat6
chown -R www-data: /etc/tomcat6

Then I was able to run tomcat6

/etc/init.d/tomcat6 start

See the results

# ps aux | grep tomcat
www-data 26436 11.3  0.7 559552 58464 ?        Sl   05:34   0:01 /usr/lib/jvm/java-6-openjdk/bin/java -Djava.util.logging.config.file=/var/lib/tomcat6/conf/logging.properties -Djava.awt.headless=true -Xmx128M -XX:+UseConcMarkSweepGC -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/usr/share/tomcat6/endorsed -classpath /usr/share/tomcat6/bin/bootstrap.jar -Dcatalina.base=/var/lib/tomcat6 -Dcatalina.home=/usr/share/tomcat6 -Djava.io.tmpdir=/tmp/tomcat6-tmp org.apache.catalina.startup.Bootstrap start
2
  • There were silent failures till I set the ownership of /usr/lib/tomcat6 and /etc/tomcat6 . Only then Tomcat served my application. Please include these crucial pieces. Jun 28, 2012 at 13:19
  • same for /var/cache/tomcat6/. Tomcat will complain about an unwritable scratch dir Jun 30, 2012 at 5:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .