I am in a messy situation that involves Apache and Tomcat 6. I serve PHP projects with Apache.

I use Tomcat to run Solr, a RESTful interface for search. I place the Solr index within the PHP application. This is helpful as all the code and data associated with a project is stored in a single directory. And it works without a hitch in our Windows development machines.

But it gets tricky in my Linode Ubuntu VPS. I log in as root using SSH and all files I write in that session are owned by root. But then,

  1. all PHP directories need to be readable and writable by www-data, which Apache runs as.
  2. the Solr indexes need to readable and writable by tomcat6, which Tomcat runs as.

Hence, my flow to deploy a new project:

  1. Log in as root with SSH and copy files to www
  2. use chown to make the project owned by www-data
  3. use chown to make the Solr index subdirectory owned by tomcat6

The obvious way to make this straightforward is to create a new user xx, and run Apache and Tomcat as xx and upload to SSH as xx. What is a good solution so that I can simply upload the files so that both Apache and Tomcat can use it straightaway without any further settings?


Put www-data and tomcat6 in the same group and add your user (or root) to that group. sg and umask so files you copy get the correct group and are g+rw.

  • After making the group make the www folder group sticky. This along with the common group and umask will make it very easy to manage the permissions. – Lamar B Oct 3 '11 at 16:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.