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,
- all PHP directories need to be readable and writable by www-data, which Apache runs as.
- the Solr indexes need to readable and writable by tomcat6, which Tomcat runs as.
Hence, my flow to deploy a new project:
- Log in as root with SSH and copy files to www
- use chown to make the project owned by www-data
- 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?