User rights setup, Tomcat and Apache users both need access to a directory
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
User rights setup, Tomcat and Apache users both need access to a directory
Hi,
I have a user rights issue that I need some help with and would appreciate any solutions/suggestions.
I have to run an app which has a few servlets that run through tomcat and some php files that are on apache web server. Code in all scripts and servlets need to access a directory on the system. The problem is, if the directory has been created by tomcat, apache cannot write into it and if apache creates a dir tomcat doesn't have write permission in it.
There is probably a very easy solution to this but I'm not very good with linux. I am running an enterprise linux 5 box.
The easiest way to do this, is to use the same user for both servers. I.e. find the user that apache runs as (usually www-data or apache depending on distro) and use that same user to start tomcat:
Thanks guys i will try that shortly and get back to you. I have previously tried adding tomcat to apache's group and change group of the main directory to apache. That way both had write access to the main directory but problem still persisted when a directory was created within that main dir by any of the users. The user that created the dir only had write permissions in it.
The easiest way to do this, is to use the same user for both servers. I.e. find the user that apache runs as (usually www-data or apache depending on distro) and use that same user to start tomcat:
Code:
su www-data -c "/path/to/tomcat/bin/startup.sh"
Regards
I think running tomcat with apache's user might stop tomcat from accessing its own resources like log files etc. I will have to go and change each of tomcat's resource and set flexible permissions on them?
I think running tomcat with apache's user might stop tomcat from accessing its own resources like log files etc. I will have to go and change each of tomcat's resource and set flexible permissions on them?
Finally, chmod g+s on those dirs, so that group owner propagates to new files:
Code:
chmod g+s /var/www
chmod g+s /var/lib/tomcat
Optionally, set umask to 0664 someplace.
That's to setup a new group and make sure that servlets and php scripts both run through that group (since users are added in that group).
what permission would i need to give to that directory that they both are accessing and writing into? Should i just change its group to webguys and leave the user to either tomcat or apache ? and what chmod would i need on it?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.