Web-server – How to make Tomcat6 on Ubuntu 11.10 run as www-data

tomcatweb-server

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.

Best Answer

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