I am deploying my Flask App on Apache server (using WSGI) and i am a bit confused with my venv. If i start my app by hand - i mean with:
flask run or python3 main.py
everything works fine. But when i try to get access through Apache i am getting error while loading modules like:
File /var/www/FlaskApp/venv/lib/python3.8/site-packages/mariadb/__init__.py, line 7
...
from ._mariadb import (
mariadb was installed through pip3 install mariadb and is located inside /var/www/FlaskApp/venv/lib/python3.8/site-packages/mariadb
I do not have any idea why everything works by hand and through Apache it doesn't. I will appreciate any help.
/etc/apache2/sites-available/FlaskApp.conf
<VirtualHost *:80>
ServerName 10.0.2.6
WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
<Directory /var/www/FlaskApp/app/>
Order allow,deny
Allow from all
</Directory>
Alias /static /var/www/FlaskApp/app/static
<Directory /var/www/FlaskApp/app/static/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
flaskapp.wsgi
#!/var/www/FlaskApp/venv/bin/python3.8
import sys, logging
activate_this = '/var/www/FlaskApp/venv/bin/activate_this.py'
with open(activate_this) as file_:
exec(file_.read(), dict(__file__=activate_this))
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/FlaskApp/app")
from main import app as application
Folder structure:
/var/www/FlaskApp/
- app/
- main.py (app.run() inside)
- static/
- venv/
- flaskapp.wsgi
Aucun commentaire:
Enregistrer un commentaire