简体   繁体   中英

Apache2 and Flask issue

I try to load my app towards my apache2 server but i keep getting error 500.

File Structure: /var/www/ApproveAndPost:

  • ApproveAndPost.wsgi
  • ApprovePost_Web
  • run.py

/var/www/ApproveAndPost/ApprovePost_Web:

  • forms.py
  • init .py
  • models.py
  • routes.py
  • services.py
  • static
  • templates

Files content: /etc/apache2/sites-available/ApproveAndPost.conf

<VirtualHost *:80>
                ServerName 192.168.170.67
                ServerAdmin email@mywebsite.com
                WSGIScriptAlias / /var/www/ApproveAndPost/ApproveAndPost.wsgi
                <Directory /var/www/ApproveAndPost/ApprovePost_Web/>
                        Order allow,deny
                        Allow from all
                </Directory>
                Alias /static /var/www/ApproveAndPost/ApprovePost_Web/static
                <Directory /var/www/ApproveAndPost/ApprovePost_Web/static/>
                        Order allow,deny
                        Allow from all
                </Directory>
                ErrorLog ${APACHE_LOG_DIR}/error.log
                LogLevel warn
                CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

WSGI File:

#!/usr/bin/python
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/ApproveAndPost")

from ApproveAndPost import app as application
application.secret_key = 'DISISSECRETKEY'

Python Code:

run.py

from ApprovePost_Web import app

if __name__ == "__main__":
    app.run(debug=True)

init .py:

from flask import Flask
from flask_sqlalchemy import SQLAlchemy


app = Flask(__name__)
app.config['SECRET_KEY'] = '#$%^&*'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///site.db'
db = SQLAlchemy(app)


from ApprovePost_Web import routes

if __name__ == "__main__":
    app.run(debug=True)

I think i am mixing up a couple of things?

The problem is essentially that you are installing Flask, and possibly other required libraries, in a virtual environment but the python (wsgi interface) is running with the system python which does not have these extra libraries installed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM