Move a flask server to production with mod_wsgi
Question: I followed this
[tutorial](http://flask.pocoo.org/docs/0.10/deploying/mod_wsgi/). Here is my
server:

    
    
    from flask import Flask
    app = Flask(__name__)
    
    @app.route('/')
    def hello_world():
        return 'Hello World!'
    
    if __name__ == '__main__':
        app.run()
    

When running

    
    
    python server.py
    curl 127.0.0.1:5000
    

I get the expected result.

Now I add a test.wsgi:

    
    
    import sys
    sys.path.insert(0, '/var/www/test')
    from server import app as application
    

and in /etc/apache2/sites-enabled/test.config:

    
    
    <VirtualHost *:5000>
    ServerName example.com
    
    WSGIDaemonProcess test user=user1 group=user1 threads=5
    WSGIScriptAlias / /var/www/test/test.wsgi
    
    <Directory /var/www/test>
        WSGIProcessGroup test
        WSGIApplicationGroup %{GLOBAL}
        Order deny,allow
        Allow from all
    </Directory>
    </VirtualHost>
    

Now calling

    
    
    sudo service apache2 restart
    curl 127.0.0.1:5000
    

will return an error. What did I do wrong?


Answer: As Daniel Roseman pointed out, I needed to

  1. Remove the ServerName directive
  2. Add `Listen 5000` to my `/etc/apache2/apache.conf` to make the server listen on port 5000

