Server as a different user

I’ve installed a LAMP server onto my Ubuntu install but I’d like the server to run as a different user. How can I do this?

I’ve finally sorted it that I can have the Apache root folder in my home directory so there’s no fancy stuff to place my files onto the server (default is /var/www which requires root permission to see)

I cant see an option anywhere. I’m using Webmin to admin the server. It’s a lot easier than adjusting it via conf files.

in the apache httpd.conf change the directives

user nobody
group nobody

then change file ownerships on executables, conf files, and specifically log files and dirs to the new username.

adjust the startup script to
su - user -c /path/to/apachectl start

I assume nobody is the username or is it set to nobody?

by default apache runs as user nobody, group nobody on most 'nix flavours, as defined in the httpd.conf :slight_smile:

You should have a login already for a user with next to no permissions on the system

Check with


# getent passwd nobody
nobody:x:99:99:Nobody:/:/sbin/nologin

If thats the case just change or uncomment the user and group entries as listed above

I get:-

chris@Tranquility:~$ getent passwd nobody
nobody:x:65534:65534:nobody:/nonexistent:/bin/sh

That what I need?

EDIT:In apache2.conf, it has user: www-data and group www-data.