I’m trying to run a basic helloworld with apache2 and mod_wsgi but depsite following the tutorial from flask documentation all i got is an error 500.
Everything is in /var/www/myapp
myapp.wsgi
from yourapplication import app as application
/etc/apache2/site-availables/default
<VirtualHost *:80>
ServerName mydomain
WSGIDaemonProcess myap user=web group=www-data threads=5
WSGIScriptAlias / /var/www/mydomain/myap.wsgi
<Directory /var/www/myapp>
WSGIProcessGroup myap
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
hello.py (flask app)
#!/usr/bin/env python
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def hello():
return render_template('hello.html')
if __name__ == '__main__':
app.run()
First, you should configure some kind of logging so you can see the actual exception behind the 500 response.
Based on your code, you may be generating an ImportError in your WSGI file when you attempt to import
appfromyourapplicationinstead ofhello. Try:You also have a couple of spots where you use
myapinstead ofmyapp, if what you posted here matches what’s on your server. Either way, logging your errors should confirm it.