Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

I have some Django sites deployed using Apache2 and mod_wsgi. When configuring the WSGIDaemonProcess directive, most tutorials (including the official documentation) suggest running the WSGI process as the user in whose home directory the code resides. For example:

WSGIScriptAlias / /home/joe/sites/
WSGIDaemonProcess user=joe group=joe processes=2 threads=25

However, I wonder if it is really wise to run the wsgi daemon process as the same user (with its attendant privileges) which develops the code. Should I set up a service account whose only privilege is read-only access to the code in order to have better security? Or are my concerns overblown?

share|improve this question

migrated from Mar 11 '11 at 19:11

This question came from our site for professional and enthusiast programmers.

up vote 2 down vote accepted

It is a good general practice to run your services with unprivileged accounts whenever possible. For processes that need root-only resources (ports < 1024, accessing certain files) the process should acquire them and then immediately drop privileges.

A few other tips.. From your phrase "run the ... process as the same user ... which develops the code" it sounds a bit like the developers are writing code on the production hosts. Are you using some form of source change control system (e.g. git, svn)? Developers should code on dev-only machines and commit to a shared repository, from which you can release stable builds. Deploy code from the repository after it is integration tested, and ideally package it for installation (DEB, RPM, EGG, etc). This will reduce errors slipping into production, make releases repeatable, avoid code loss if a host drops dead, and so on.

share|improve this answer

You'd better do chown www-user:www-data -R dirname of your code(Or apache:apache). The most important data on your pc is your, user data, so moving services away from your user is better.

share|improve this answer

The reason that you find it said that user should be that of the home directory is because on many systems the home directory has permissions of 'drwx------' which means that only the user can read stuff in there. So, you basically have no choice if you are going to put stuff in a home directory of a user.

You would also find it suggested that it is therefore better not to have it in your home directory at all and instead place it where other web server stuff is, but not under the DocumentRoot of any virtual server or the main server. By doing that, the directory restrictions aren't going to apply and Apache user could read it.

Overall the best idea, especially if the box is also your own development machine, is to do a separate deploy of code into this separate area, making code files non writable and then running it all as some separate dedicated non privileged user.

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.