?
Solved

How can I start the apache with specific user account?

Posted on 2002-03-06
13
Medium Priority
?
378 Views
Last Modified: 2010-03-04
Hi,
   I want to start the apache service on UNIX platform with specific user, e.g "root".  How can I set it?  Thanks
0
Comment
Question by:HenryChang
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +2
13 Comments
 
LVL 1

Expert Comment

by:johnnyp
ID: 6843907
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.
0
 
LVL 15

Expert Comment

by:samri
ID: 6844369
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").
0
 
LVL 2

Expert Comment

by:mhonomichl
ID: 6846174
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.
0
Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

 
LVL 15

Expert Comment

by:samri
ID: 6846342
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
0
 
LVL 1

Expert Comment

by:johnnyp
ID: 6846752
Isn't all this what I said to begin with!!!!!!!!!!!!!!!!!
0
 
LVL 15

Expert Comment

by:samri
ID: 6847422
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,
0
 
LVL 1

Expert Comment

by:johnnyp
ID: 6847439
:-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.
0
 
LVL 2

Expert Comment

by:mhonomichl
ID: 6847879
johnnyp -

Don't confuse your lack of articulation with plagiarism.  
0
 
LVL 15

Accepted Solution

by:
samri earned 400 total points
ID: 6849279
johnnyp,

Yes mhonomichl is correct.  That's the only way to get the problem solved, and when if comes to building software under Unix (or any C code), one would be looking and configuration file (so called ./Configure), make utilitiy, all the configuration switches, so forth.

The goal here is to help  HenryChang to get his problem solved, it's not about points (Heck, I wish I can buy cars with those).

I do agree with you that some portion of my solution (and even mhonomichl's) do sound like what you said.  THe problem is, yours are too simple, and too vague.  In fact I can go around in every SubjectArea, and start posting  "I used to do that", or "Make sure you configuration is correnct", or "Have you checked you XXXX installation", etc.  And when somebody else, started to detailed out, which portion of Configuration should be fixed in detail, or what to look in "what" log file, etc.  Did he/she use my idea?  Of course he/she did, but to elaborate further -  this is called Teamwork.  

Look back at EE policy

http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp
http://www.experts-exchange.com/jsp/cmtyQuestAnswer.jsp 
0
 
LVL 5

Expert Comment

by:Netminder
ID: 6849649
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
0
 
LVL 15

Expert Comment

by:samri
ID: 6928096
HenryChang,

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

cheers
0
 
LVL 15

Expert Comment

by:periwinkle
ID: 9678860
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
0

Featured Post

Building an interactive eFuture classroom

Watch and learn how ATEN provided a total control system solution including seamless switching matrix switch, HDBaseT extenders, PDU, lighting control to build an interactive eFuture classroom.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question