apache2, mod_wsgi, python web app (bottle framework)

后端 未结 3 1659
一向
一向 2021-01-16 12:07

Note: I guess the bottle framework is not relevant here. Wsgi is.

I\'ve managed to configure my apache to work with wsgi and one-file web applicatio

3条回答
  •  无人共我
    2021-01-16 12:41

    I tried Graham's suggestion but it didn't work for me.

    Here is what worked for me:
    [BTW, I am working on OSX. Please adjust the paths, user, group according to your operating system]

    /Library/WebServer/Documents/hello_app/app.wsgi:

    import sys
    
    sys.path.insert(0, "/Library/WebServer/Documents/hello_app")
    
    import bottle
    import hello
    application = bottle.default_app()
    

    /Library/WebServer/Documents/hello_app/hello.py:

    from bottle import route
    
    @route('/hello')
    def hello():
        return "Hello World!"
    

    /etc/apache2/extra/httpd-vhosts.conf:

    
        ServerName xyz.com
    
        WSGIDaemonProcess hello_app user=_www group=_www processes=1 threads=5
        WSGIScriptAlias /v1 /Library/WebServer/Documents/hello_app/app.wsgi
    
        
            WSGIProcessGroup hello_app
            WSGIApplicationGroup %{GLOBAL}
            Order deny,allow
            Allow from all
        
    
    

    Don't forget to restart your apache server.

    Check the app in the web browser

提交回复
热议问题