[Python] Flask app not working with apache2 wsgi file

Discussão em 'Python' iniciado por Stack, Março 12, 2025.

  1. Stack

    Stack Membro Participativo

    I have a python flask app on my /home/ubuntu/dev/test folder that if I run python test.py, I can receive a * Running on http://127.0.0.1:5000 and successfully test it locally.

    But when I try to use this app in my Apache 2 server with wsgi, It's not working. The test.wsgi file is inside my /home/ubuntu/dev/test folder with the .py file:

    import sys
    sys.path.insert(0, '/home/ubuntu/dev/test')
    from test import app as application


    The files permissions are -rwxr-xr-x 1 ubuntu ubuntu

    and in my 000-default.conf I have:

    <VirtualHost *:80>
    # RewriteEngine On
    # RewriteCond %{HTTPS} !=on
    # RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R=301,L]
    # ServerName MY-SERVER
    # Redirect permanent / https://MY-ADDRESS

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    WSGIDaemonProcess test threads=5
    WSGIScriptAlias / /home/ubuntu/dev/test/test.wsgi
    <Directory /home/ubuntu/dev/test>
    WSGIProcessGroup test
    WSGIApplicationGroup %{GLOBAL}
    Order deny,allow
    Allow from all
    </Directory>


    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    </virtualhost>


    Any ideas of what I'm doing wrong?

    Continue reading...

Compartilhe esta Página