python - flask running in mod_wsgi cannot write to /tmp -
apache v2.4.12-2
mod_wsgi v4.4.8-1
python v3.4.2
python-flask v0.10.1-5
arch linux - kernel 3.12.36
i'm using mod_wsgi , flask host server. able reproduce issue following simplified code , generic .wsgi script:
mainserver.py:
import flask app = flask.flask(__name__) @app.before_first_request def initstuff(): test_file = '/tmp/test' open(test_file, 'w') f: f.write('test') @app.route('/', methods=['get']) def rootdir(): return 'hello world'
mainserver.wsgi:
from mainserver import app application
expected: file contents 'test' written in /tmp
actual outcome: no file written. no errors reported in log
if run same code instead point other directory user has permission write, creates file expected. /tmp directory having issue.
if run above code directly , use flask's built in server (app.run), can create file in /tmp expected without issues.
i've ensured mod_wsgi server running same user script app.run , user able write /tmp.
--edit--
running httpd directly command line not cause issue. starting httpd systemd service does
i think related answer: https://unix.stackexchange.com/questions/167835/where-apaches-tmp-located
apache might using private-tmp causes /tmp redirected /var/tmp/systemd-private--httpd.service-/
Comments
Post a Comment