I'm using Apache2 to deploy a django app, I've set apache2 to a different user then apache. The problem is that when the server runs the user changes but the home directory environment variabile($HOME) remains /root.Why is that ?
I'm not an expert with the internals of Linux/Unix, but I think the system call that changes the effective user ID doesn't change any environment variables.
Environment variables would only get involved if a new process was being exec()'d or spawn()'d, i.e., when you start Apache.
You can write a small wrapper script to set $HOME to another value, and then start Apache. If you are using Debian, you can just modify /etc/init.d/apache2.