Change the user Apache runs as Need help to create a new user to apache web server and assign root privileges to newly created user. Or how to login as root user in apache server because following php script showing you are logged in as 

&lt;?php echo `whoami`; ?&gt;



  nobody.
There really isn't a good reason to run your web server as root. It opens you up to all kinds of potential abuse. OS X defaults to running the service as a severely under privileged user to protect you.

Don't make these changes unless you're absolutely certain you know what you're doing!

The httpd.conf file for the default Apache2 installation that comes with OS X can be found in /private/etc/apache2/httpd.conf. Before you make any changes to this file BACK IT UP! That way you can get back to a sane starting place if you make a catastrophically bad change.

Open the file in a text editor and look for the following lines:

# 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 _www
Group _www


The _www user/group is the default for OS X. If you want to run the server as root you'll need to change this to the appropriate user. For root:

User root
Group wheel


The plist that describes the Apache service to launchd is at /System/Library/LaunchDaemons/org.apache.httpd.plist -- OS X runs any launchd runs daemons described in this location as root so the server starts with sufficient privledges to change context to another user.

Once you've made the changes, restart Apache with:

sudo /usr/sbin/apachectl restart


and you should be running as root.

Again: BE CAREFUL DOING THIS!