0

The flask server was running perfectly fine but then I wanted to put it under apache server on ubuntu, however, for some reason, the wsgi script is not read and the web server url gives me 404 not found. I also realized that the WSGIScriptAlias is not recognized even though it doesn't show an error, because it's the only argument thats not colored in vim, so apparently the config file doesn't recognize it.

The packages installed are apt-get install libapache2-mod-wsgi-py3 python-dev and a2enmod wsgi enabled.

Here is the flaskapp.wsgi

<VirtualHost *:80>
                LoadModule wsgi_module     /usr/lib/apache2/modules/mod_wsgi.so
                ServerName user-management
                ServerAdmin o.aa@example.com
                WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
                <Directory /var/www/FlaskApp/customer-account-automation/>
                        Allowoverride None
                        Require all granted
                </Directory>
                Alias /static /var/www/FlaskApp/customer-account-automation/static
                <Directory /var/www/FlaskApp/customer-account-automation/static/>
                        AllowOverride None
                        Require all granted
                </Directory>

                Alias /templates /var/www/FlaskApp/customer-account-automation/templates
                <Directory /var/www/FlaskApp/customer-account-automation/templates/>
                        AllowOverride None
                        Require all granted
                </Directory>

                ErrorLog ${APACHE_LOG_DIR}/error.log
                LogLevel warn
                CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Here is the flaskapp.wsgi

#!/usr/bin/python3
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/customer-account-automation/")

from app import app as application
application.secret_key = 'secret'

This is the tree of the /var directory

└── www
    ├── FlaskApp
    │   ├── customer-account-automation
    │   │   ├── Pipfile
    │   │   ├── Pipfile.lock
    │   │   ├── README.md
    │   │   ├── app.py
    │   │   ├── customerAccountMgmt.py
    │   │   ├── get-pip.py
    │   │   ├── static
    │   │   │   ├── app.js
    │   │   │   ├── bulma.min.css
    │   │   │   ├── highlight.min.css
    │   │   │   ├── highlight.min.js
    │   │   │   └── styles.css
    │   │   └── templates
    │   │       ├── 404.html
    │   │       ├── base.html
    │   │       ├── change_password.html
    │   │       ├── create_user.html
    │   │       ├── deactivate_user.html
    │   │       └── login.html
    │   └── flaskapp.wsgi
    └── html
        └── index.html
Omar Abdelrazik
  • 683
  • 2
  • 9
  • 30

0 Answers0