flask running in mod_wsgi cannot write to /tmp flask running in mod_wsgi cannot write to /tmp flask flask

flask running in mod_wsgi cannot write to /tmp


I think is related to this answer:https://unix.stackexchange.com/questions/167835/where-apaches-tmp-located

Apache might be using private-tmp which causes /tmp to be redirected to /var/tmp/systemd-private--httpd.service-/


Try setting the app logger level to DEBUG (and adding a Handler):

import loggingfrom logging.handlers import RotatingFileHandlerimport flaskapp = flask.Flask(__name__)@app.before_first_requestdef initstuff():    test_file = '/tmp/test'    with open(test_file, 'w') as f:        f.write('test')@app.route('/', methods=['GET'])def rootdir():    return 'Hello world'if __name__ == '__main__':    handler = RotatingFileHandler('app.log', maxBytes=10000, backupCount=1)    handler.setLevel(logging.DEBUG)    app.logger.addHandler(handler)    app.run(host='0.0.0.0', port=8056, debug=True, use_reloader=False)

Then look in app.log to see what the problem is.