LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices



Reply
 
Search this Thread
Old 12-17-2007, 07:11 PM   #1
jlukensow
Member
 
Registered: Mar 2007
Posts: 33

Rep: Reputation: 15
Running Apache as a certain user


I know that you can run apache as a certain user, and group. But my question is, I have multiple vhost on my Linux server, is there a way to run apache for each vhost that is configured, as each user.

Example. If I have a user james, matt, and john, can I set up apache as 3 different users?
 
Old 12-17-2007, 07:44 PM   #2
Shade
Senior Member
 
Registered: Mar 2003
Location: Burke, VA
Distribution: RHEL, Slackware, Ubuntu, Fedora
Posts: 1,418
Blog Entries: 1

Rep: Reputation: 46
I imagine the reason you want to do this is for serving pages out of the users' home directories? Is this correct?

In any case, this isn't usually done. Standard practice is to assign those users to the apache group rather than have apache run as those users.

What is it that you are trying to achieve?
 
Old 12-17-2007, 07:45 PM   #3
dkm999
Member
 
Registered: Nov 2006
Location: Seattle, WA
Distribution: Fedora
Posts: 407

Rep: Reputation: 35
According to my documentation, since version 2.0, the User configuration command, which would be used to make this happen, is only valid in the global context, meaning that it applies to all virtual servers that run on a single machine. The only way that I can see to get the effect you want is to have your system respond to several IP addresses, and configure a separate httpd instance (with its own configuration file specifying the IP address to listen on) for each user.

This is less efficient, and (probably) more costly, but could produce the result you said you wanted. Otherwise, you are stuck with all virtual servers using the same User/Group spec. This may not be too bad if you use the default protections (755 or 750), since you can establish each user's webspace with them as owner, and a group that includes apache as a legal member. The only other problem is script privileges; for that there is a separate facility called suExec; I recommend a good read of the manual for that if script execution is what you are trying to control.
 
Old 12-17-2007, 08:04 PM   #4
adamben
Member
 
Registered: Feb 2007
Distribution: slackware,gentoo,ubuntu
Posts: 50

Rep: Reputation: 17
Running Apache as a certain user.

You may be interested in:
http://httpd.apache.org/docs/2.2/mod/mod_suexec.html
 
Old 12-18-2007, 10:52 AM   #5
jlukensow
Member
 
Registered: Mar 2007
Posts: 33

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Shade View Post
I imagine the reason you want to do this is for serving pages out of the users' home directories? Is this correct?

In any case, this isn't usually done. Standard practice is to assign those users to the apache group rather than have apache run as those users.

What is it that you are trying to achieve?
The reason I'm trying to do this is as follows. I'm currently hosting 3 websites, two of them are mine, and one is my buddy's. I set it up, which might be wrong, by creating 3 different users, and serving the web docs out of public_html in their directories.

Now the problem occurs when I use Joomla. When I first copy all the files and folders into the directory, everything is good. Ownership is "james:users" on all files and folders. But when I am using Joomla, and I install a third party component, that components folder, and files, are now "www:users". And sometimes, when I am using the administrator panel, and want to remove that component, it fails, becuase of ownership problems.

So I'm trying to figure out a way, that is consistent throughout.
 
Old 12-19-2007, 03:46 PM   #6
jlukensow
Member
 
Registered: Mar 2007
Posts: 33

Original Poster
Rep: Reputation: 15
Anyone have any ideas on this topic?
 
Old 12-19-2007, 09:13 PM   #7
pengaru
LQ Newbie
 
Registered: Dec 2007
Distribution: GNU/Linux
Posts: 9

Rep: Reputation: 0
Suexec will enable you to run the cgi (I presume joomla is a cgi) as different users providing you set a User and Group in the respective virtualhost sections.

If you are running Joomla via something like mod_perl or mod_php you are going to have a headache... Because this will execute the scripts as the user & group apache runs as without the possibility of suexec wrapping.

The files and directories created by Joomla will have ownership reflecting the process' user and group. This is why if suexec is used it will be a better fit for your home-directory seperation, this creates new processes and switches to the appropriate user and group.

The mod_perl/mod_php approach runs the dynamic parts in the apache process context, largely incompatible with traditional apache-based virtual hosting.

hope that helps.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Running Apache as 'deamon' user/group. Drahcir Linux - Server 1 06-28-2007 07:28 AM
Running Apache as root user on an embedded distribution sharad Linux - General 1 09-11-2006 04:01 AM
Apache running program when user leaves page The_Nerd Linux - Software 0 05-23-2004 03:30 PM
[apache] running user scripts. yapp Linux - Software 0 10-03-2003 06:00 AM
Running programs as Apache user foobarrister Linux - Software 0 03-10-2003 09:26 AM


All times are GMT -5. The time now is 11:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration