Link to home
Start Free TrialLog in
Avatar of HenryChang
HenryChang

asked on

How can I start the apache with specific user account?

Hi,
   I want to start the apache service on UNIX platform with specific user, e.g "root".  How can I set it?  Thanks
Avatar of johnnyp
johnnyp

I am pretty certain that the first instance of httpd will always run as root.  The other 4 httpd processes, unless you changed the value of StartServers in your httpd.conf file, will run as the user you have specified in the httpd.conf (defaults to nobody).

Have you compiled apache from source or are you using an RPM?  If source, check ./configure --help there may be an option to set the username to run apache as.  I can't remember as its been a while since I compiled from source.
I think you should be able to run apache as any user, any user EXCEPT root, or specifically all user except those with UID 0.  Otherwise necessary, if you still insist on running as root, you will need to recompile apache, and specify the

If you want to configure apache to run as other user, look for the following Directive in httpd.conf, and changed it to whateer user (must exist in /etc/passwd), and rule applies  the same thing with group.

User www    
Group www  

Some caution, the directory where apache needs to write it;s PID file, logfiles, should be writeable by this user, or atlest group-writable by specified Group (in this case "www").
Any port below 1024 (eg 80 for http) has to be run by root.  Apache runs it's master process as root, then spawns the rest of the process based on what is specified in the httpd.conf file as user and group.  You never want to run it as root completely, otherwise people can do some nasty things to the server.

Now, if you are just talking about starting the process (not how it runs), it has to be started as root because of the 1024 issue.  If you are looking to let another user be able to start it without giving them access to root, the best way to do it is with sudo.
I tried to simulate with no success.

1. Upack apachec tarball, and run the configure scrips;

./configure --server-uid=root --server-gid=root

2. make, and make install.  Still does not work.
Apache still complains to add the following entry to EXTRA_CFLASG -DBIG_SECURITY_HOLE

3. I added the following -DBIG_SECURITY_HOLE to every,
EXTRA_CFLAGS in every Makefile I found.

4.  Compile, and make install.

5.  Make sure your httpd.conf has the right user/grou in it's User/Group Directive (root/root).

Ttry to start it.  And voila.  all httpd should be running by root now.

And you have be warned, running Apache as root is a BIG mistake.

I wonder why you still require the server to run as root.  If we could offer a better alternative to that.

good luck
Isn't all this what I said to begin with!!!!!!!!!!!!!!!!!
johnnyp,

Yes, you are correct.  At least the "configure" is.  But that alone would not do any good.  Btw, have you tested the claim anyway.  I tried it and Apache still complains (at least on my machine - RH 7.2, Apache 1.3.23), it still refuses to run.  Added -DBIG_SECURITY_HOLE in src/Configuration as written in docs, does not work.  I end-up manually adding the flag in every Makefile (kinda stupid - I am not a C programmer).

If you had better alternatives, I certainly (or HenryChang would be most) likely would like to hear that, rather than bragging about a "hint" that you just gave.

cheers,
:-D

Bragging!!!!!  I'm not bragging at all.  It's just that both of you have stated exactly what I said in the first place without reference to the fact that its already been said.  If your that desperate to get the points then go for it, knock yourself out.  I've got better things to do that start arguing with people on a website.
johnnyp -

Don't confuse your lack of articulation with plagiarism.  
ASKER CERTIFIED SOLUTION
Avatar of samri
samri
Flag of Malaysia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Folks,

Let's see if we can keep the discussion on a professional, collaborative level; besides being completely unbecoming, it contributes to neither solving the Asker's problem nor to anyone's credibility as an Expert.

It is commonplace for one Expert to make a suggestion, and to have another expand on it; none of us can know how much information HenryChang had going in, and lacking any response from him, we can't know which, if any, of the suggestions were useful to him. Given his grading history, I'd be a little surprised if he decided a quick fix wasn't forthcoming, and has abandoned the question. If nothing else, your collective... behavior... has caused me to add yet another name to my list of people who will get at least one email from Admin. <grin>

It is perfectly possible (and altogether frequent, though in this case unlikely) that HenryChang will find a number of your collective suggestions at least partially useful, and will make the decision to split the points among you. He may also decide to award the points to the Expert who helped him the most. That's HIS decision, and his alone, unless he continues to demonstrate his deplorable tendency to make promises he has no intention of keeping -- but I'll deal with that when I have to.

In the meantime, let's leave the digs, insults, name-calling and so on at some other website, okay?

Netminder
Community Support Moderator
Experts Exchange
HenryChang,

Does any of our proposed solution works, or are you still tweaking your Apache?

cheers
Avatar of periwinkle
No comment has been added lately, so it's time to clean up this TA.

I will leave a recommendation in the Cleanup topic area with the following recommendation for this question:

Answered by samri

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

periwinkle
EE Cleanup Volunteer