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.

Jesvin Jose
  • 113
  • 5

1 Answers1

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
Mike
  • 22,310
  • 7
  • 56
  • 79
  • 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. – Jesvin Jose Jun 28 '12 at 13:19
  • same for `/var/cache/tomcat6/`. Tomcat will complain about an unwritable scratch dir – Jesvin Jose Jun 30 '12 at 05:31