Reputation: 425
I'm trying to configure my wsgi app to run under my user id. The OS is Ubuntu 13.10. This is virtual host config:
<VirtualHost *:80>
ServerName lz5.local
DocumentRoot /home/kompas/git/lz5/front-app
WSGIDaemonProcess lz user=#1000 group=#1000
WSGIApplicationGroup lz
<Directory /home/kompas/git/lz5>
AllowOverride None
Require all granted
</Directory>
LogFormat "%V %l %u %t \"%r\" %>s %b" common_vhost
CustomLog "/var/log/apache2/logzilla_access.log" common_vhost
ErrorLog "/var/log/apache2/logzilla_error.log"
WSGIScriptAlias /api /home/kompas/git/lz5/app.wsgi
</VirtualHost>
And this is my app.wsgi:
(...imports...)
sys.stderr.write("My uid={}, gid={}, euid={}, egid={}".format(
os.getuid(), os.getgid(), os.geteuid(), os.getegid()))
sys.stderr.flush()
application = make_app()
application.debug = True
It seems to be working fine:
[Wed Mar 12 09:55:45.059101 2014] [:info] [pid 25068:tid 139724309714816] mod_wsgi (pid=25068): Starting process 'lz' with uid=1000, gid=1000 and threads=15.
...but in the app.wsgi uid is not changed:
[Wed Mar 12 09:55:49.457056 2014] [:error] [pid 25070:tid 139724094150400] My uid=33, gid=33, euid=33, egid=33
I also noticed, that there's some apache process group with uid set properly to "kompas" (uid 1000), but this is not the one which runs my app!
apache2(23368)─┬─apache2(25479,www-data)─┬─{apache2}(25526)
...
├─apache2(25480,www-data)─┬─{apache2}(25499)
│ ├─{apache2}(25500)
...
└─apache2(25478,kompas)─┬─{apache2}(25481)
├─{apache2}(25482)
But the pid I get from my app.wsgi is 25480, not 25478 as I'd expect.
Any ideas?
Upvotes: 1
Views: 2228
Reputation: 58563
You are missing a WSGIProcessGroup directive to tell mod_wsgi what daemon process group to run your application in.
Go read:
What you should be using is:
WSGIProcessGroup lz
WSGIApplicationGroup %{GLOBAL}
Upvotes: 4