Bell Eapen MD, PhD.

Bringing Digital health & Gen AI research to life!

Running Tomcat as www-data

For last couple of days I have been working on a web based application for skin color measurement as I blogged here. The core of the application is implemented in php as it is much easier to handle. (May be I am more comfortable with it). But the GD image library for php has limited functionality. So I had to rely on Java for border detection and segmentation. So I implemented part of the functionality as a servlet running on tomcat6.

Today's latte, Apache Tomcat.
Today’s latte, Apache Tomcat. (Photo credit: yukop)

Both php and servlet had to read and write same files. But standard configuration does not allow this as php creates files as www-data (apache user) and tomcat creates files as tomcat6 user. I searched the internet for solutions. One suggestion was to create an appropriate umask for both which I could never completely understand. Finally I realised that the easiest solution is to make tomcat run as user www-data so that all created files will have same ownership.

I found this webpage with detailed instructions on how to do this. I would like to add two more steps:
1. Edit /etc/init.d/tomcat6 also to add the user ID and group ID
2. chown var/cache/tomcat6 directory also.

Nina Jablonski - The Evolution of Human Skin Color
Nina Jablonski – The Evolution of Human Skin Color (Photo credit: wagnerfreeinstitute)

BTW the application is hosted on my laptop. If you want to check it out click on the banner below if you see it. You will see it only when my laptop is on.