python - mod_wsgi working directory and user -
i'm running flask on mod_wsgi. flask app, on /var/www/app
receives file user , saves /var/www/app/tmp
directory. after chmod , chown(thought permission problem), unable reach tmp directory.
after debugging found out current working directory of flask app /
. can alter working directory os.chdir('/var/www/')
, i'd avoid security concerns.
here apache configuration:
<virtualhost *:80> servername mysite.com serveralias site.com serveradmin admin@localhost wsgidaemonprocess app user=www-data group=www-data processes=1 wsgiscriptalias / /var/www/app.wsgi alias /static /var/www/app/static <directory /var/www/app> wsgiprocessgroup app wsgiapplicationgroup %{global} wsgiscriptreloading on order deny,allow allow </directory> <location "/static"> sethandler none </location> </virtualhost>
how can alter working directory of app /
/var/www
?
the documentation wsgidaemonprocess says can utilize home=...
stanza:
home=directory
defines absolute path of directory should used initial current working directory of daemon processes within process group. if alternative not defined, in mod_wsgi 1.x current working directory of apache parent process inherited daemon processes within process group. current working directory of apache parent process root directory. in mod_wsgi 2.0+ initial current working directory set home directory of user daemon process runs as.
i'm curious, though -- why using os.chdir
more of security risk in opinion?
python apache2 mod-wsgi
No comments:
Post a Comment