Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I run a webserver on boot without root rights (as another user)? I could just add it in rc.local, but it's run under root user.

share|improve this question

How can i run a webserver on boot without root rights (as another user)?

Why? What are you trying to achieve?

The first thing Apache does after becoming a daemon and listeing on a port is to setuid to the user defined in the config files - i.e. it does not run with root rights.

It's impossible to start a daemon listening on a port below 1024 unless you are root - but its perfectly possible to start it listening on, say port 8000, and also quite possible to set up iptables to proxy port 80 requests to port 8000 - but only root processes can setuid to a different uid - so you'll need to change your Apache config so that either it doesn't call setuid, or it only calls setuid to the current uid.

If you are concerned about security then there are lots of other things you should consider doing before you try to repair a security hole which is effectively non-existant.


share|improve this answer

Search for the following section in the httpd config file:

# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.  
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
User daemon
Group daemon

and change the 'daemon' user and group to the required user name.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.