apache flask sqlite无法在Ubuntu上打开数据库文件

问题描述 投票:0回答:1

首先,我尝试使用Flask服务器运行该应用程序,并且运行良好这是错误日志

[Mon Jan 06 08:57:53.680218 2020] [mpm_event:notice] [pid 3499:tid 139791901608896] AH00491: caught SIGTERM, shutting down
[Mon Jan 06 08:57:53.733321 2020] [mpm_event:notice] [pid 3572:tid 140391160454080] AH00489: Apache/2.4.29 (Ubuntu) mod_wsgi/4.5.17 Python/2.7 configured -- resuming normal operations
[Mon Jan 06 08:57:53.733463 2020] [core:notice] [pid 3572:tid 140391160454080] AH00094: Command line: '/usr/sbin/apache2'
[Mon Jan 06 08:57:55.712042 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141] mod_wsgi (pid=3573): Target WSGI script '/var/www/FlaskApp/flaskapp.wsgi' cannot be loaded as Python module.
[Mon Jan 06 08:57:55.712087 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141] mod_wsgi (pid=3573): Exception occurred processing WSGI script '/var/www/FlaskApp/flaskapp.wsgi'.
[Mon Jan 06 08:57:55.712124 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141] Traceback (most recent call last):
[Mon Jan 06 08:57:55.712141 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]   File "/var/www/FlaskApp/flaskapp.wsgi", line 10, in <module>
[Mon Jan 06 08:57:55.712191 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]     from FlaskApp import app as application
[Mon Jan 06 08:57:55.712206 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]   File "/var/www/FlaskApp/FlaskApp/__init__.py", line 9, in <module>
[Mon Jan 06 08:57:55.712339 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]     from database_setup import Department, Base, Req_Status, Req_Priorities, Time_Units, Req_Type, Requests, User
[Mon Jan 06 08:57:55.712367 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]   File "/var/www/FlaskApp/FlaskApp/database_setup.py", line 77, in <module>
[Mon Jan 06 08:57:55.712440 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]     Base.metadata.create_all(engine)
[Mon Jan 06 08:57:55.712454 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/schema.py", line 4316, in create_all
[Mon Jan 06 08:57:55.713290 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]     ddl.SchemaGenerator, self, checkfirst=checkfirst, tables=tables
[Mon Jan 06 08:57:55.713307 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 2048, in _run_visitor
[Mon Jan 06 08:57:55.713698 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]     with self._optional_conn_ctx_manager(connection) as conn:
[Mon Jan 06 08:57:55.713711 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]   File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
[Mon Jan 06 08:57:55.713758 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]     return self.gen.next()
[Mon Jan 06 08:57:55.713768 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 2040, in _optional_conn_ctx_manager
[Mon Jan 06 08:57:55.713781 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]     with self._contextual_connect() as conn:
[Mon Jan 06 08:57:55.713803 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 2242, in _contextual_connect
[Mon Jan 06 08:57:55.713814 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]     self._wrap_pool_connect(self.pool.connect, None),
[Mon Jan 06 08:57:55.713821 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 2280, in _wrap_pool_connect
[Mon Jan 06 08:57:55.713831 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]     e, dialect, self
[Mon Jan 06 08:57:55.713839 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1547, in _handle_dbapi_exception_noconnection
[Mon Jan 06 08:57:55.713848 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]     util.raise_from_cause(sqlalchemy_exception, exc_info)
[Mon Jan 06 08:57:55.713856 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/compat.py", line 398, in raise_from_cause
[Mon Jan 06 08:57:55.713968 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]     reraise(type(exception), exception, tb=exc_tb, cause=cause)
[Mon Jan 06 08:57:55.713977 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 2276, in _wrap_pool_connect
[Mon Jan 06 08:57:55.713987 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]     return fn()
[Mon Jan 06 08:57:55.713995 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool/base.py", line 363, in connect
[Mon Jan 06 08:57:55.714163 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]     return _ConnectionFairy._checkout(self)
[Mon Jan 06 08:57:55.714181 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool/base.py", line 760, in _checkout
[Mon Jan 06 08:57:55.714193 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]     fairy = _ConnectionRecord.checkout(pool)
[Mon Jan 06 08:57:55.714200 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool/base.py", line 492, in checkout
[Mon Jan 06 08:57:55.714209 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]     rec = pool._do_get()
[Mon Jan 06 08:57:55.714216 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool/impl.py", line 238, in _do_get
[Mon Jan 06 08:57:55.714303 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]     return self._create_connection()
[Mon Jan 06 08:57:55.714312 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool/base.py", line 308, in _create_connection
[Mon Jan 06 08:57:55.714323 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]     return _ConnectionRecord(self)
[Mon Jan 06 08:57:55.714330 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool/base.py", line 437, in __init__
[Mon Jan 06 08:57:55.714339 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]     self.__connect(first_connect_check=True)
[Mon Jan 06 08:57:55.714346 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool/base.py", line 639, in __connect
[Mon Jan 06 08:57:55.714355 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]     connection = pool._invoke_creator(self)
[Mon Jan 06 08:57:55.714362 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/strategies.py", line 114, in connect
[Mon Jan 06 08:57:55.714431 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]     return dialect.connect(*cargs, **cparams)
[Mon Jan 06 08:57:55.714440 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 482, in connect
[Mon Jan 06 08:57:55.714691 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141]     return self.dbapi.connect(*cargs, **cparams)
[Mon Jan 06 08:57:55.714736 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141] OperationalError: (sqlite3.OperationalError) unable to open database file
[Mon Jan 06 08:57:55.714742 2020] [wsgi:error] [pid 3573:tid 140391057372928] [client 10.10.30.35:59141] (Background on this error at: http://sqlalche.me/e/e3q8)
[Mon Jan 06 08:57:55.852806 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142] mod_wsgi (pid=3573): Target WSGI script '/var/www/FlaskApp/flaskapp.wsgi' cannot be loaded as Python module., referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.852847 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142] mod_wsgi (pid=3573): Exception occurred processing WSGI script '/var/www/FlaskApp/flaskapp.wsgi'., referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.852904 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142] Traceback (most recent call last):, referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.852949 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]   File "/var/www/FlaskApp/flaskapp.wsgi", line 10, in <module>, referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.852991 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]     from FlaskApp import app as application, referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853011 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]   File "/var/www/FlaskApp/FlaskApp/__init__.py", line 9, in <module>, referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853026 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]     from database_setup import Department, Base, Req_Status, Req_Priorities, Time_Units, Req_Type, Requests, User, referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853034 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]   File "/var/www/FlaskApp/FlaskApp/database_setup.py", line 77, in <module>, referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853046 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]     Base.metadata.create_all(engine), referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853053 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/schema.py", line 4316, in create_all, referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853066 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]     ddl.SchemaGenerator, self, checkfirst=checkfirst, tables=tables, referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853074 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 2048, in _run_visitor, referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853085 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]     with self._optional_conn_ctx_manager(connection) as conn:, referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853092 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]   File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__, referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853102 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]     return self.gen.next(), referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853109 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 2040, in _optional_conn_ctx_manager, referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853118 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]     with self._contextual_connect() as conn:, referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853125 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 2242, in _contextual_connect, referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853135 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]     self._wrap_pool_connect(self.pool.connect, None),, referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853141 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 2280, in _wrap_pool_connect, referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853151 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]     e, dialect, self, referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853157 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1547, in _handle_dbapi_exception_noconnection, referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853167 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]     util.raise_from_cause(sqlalchemy_exception, exc_info), referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853174 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/compat.py", line 398, in raise_from_cause, referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853191 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]     reraise(type(exception), exception, tb=exc_tb, cause=cause), referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853198 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 2276, in _wrap_pool_connect, referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853208 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]     return fn(), referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853215 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool/base.py", line 363, in connect, referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853226 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]     return _ConnectionFairy._checkout(self), referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853232 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool/base.py", line 760, in _checkout, referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853242 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]     fairy = _ConnectionRecord.checkout(pool), referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853249 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool/base.py", line 492, in checkout, referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853258 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]     rec = pool._do_get(), referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853265 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool/impl.py", line 238, in _do_get, referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853275 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]     return self._create_connection(), referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853282 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool/base.py", line 308, in _create_connection, referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853291 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]     return _ConnectionRecord(self), referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853298 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool/base.py", line 437, in __init__, referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853307 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]     self.__connect(first_connect_check=True), referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853314 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool/base.py", line 639, in __connect, referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853323 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]     connection = pool._invoke_creator(self), referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853329 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/strategies.py", line 114, in connect, referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853339 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]     return dialect.connect(*cargs, **cparams), referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853346 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]   File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 482, in connect, referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853360 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142]     return self.dbapi.connect(*cargs, **cparams), referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853390 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142] OperationalError: (sqlite3.OperationalError) unable to open database file, referer: http://10.10.30.99/
[Mon Jan 06 08:57:55.853395 2020] [wsgi:error] [pid 3573:tid 140391040587520] [client 10.10.30.35:59142] (Background on this error at: http://sqlalche.me/e/e3q8), referer: http://10.10.30.99/

我的连接字符串init。py是

from flask import Flask, render_template, request, redirect, url_for, flash
from flask_bootstrap import Bootstrap
from flask_wtf import FlaskForm 
from wtforms import StringField, PasswordField, BooleanField
from wtforms.validators import InputRequired, Email, Length
from flask_sqlalchemy  import SQLAlchemy
from werkzeug.security import generate_password_hash, check_password_hash
from flask_login import LoginManager, UserMixin, login_user, login_required, logout_user, current_user
from database_setup import Department, Base, Req_Status, Req_Priorities, Time_Units, Req_Type, Requests, User
from sqlalchemy import create_engine, asc
from sqlalchemy.orm import sessionmaker
from flask import session as Session
from flask_table import Table, Col
from sqlalchemy import desc
from flask_wtf import Form
from wtforms.fields.html5 import DateField
from datetime import datetime
from datetime import timedelta
from sqlalchemy import exc
import random
import time
app = Flask(__name__)
bootstrap = Bootstrap(app)
engine = create_engine('sqlite:////var/www/FlaskApp/FlaskApp/IT_DataBase.db',
                       connect_args={'check_same_thread': False,'timeout': 15})
Base.metadata.bind = engine
DBSession = sessionmaker(bind=engine)
session = DBSession()
db = SQLAlchemy(app)

/ var / www /中我的文件层次结构是

  • FlaskApp
    • flaskapp.wsgi
    • FlaskApp
      • 静态
      • 模板
      • venv
      • init。py
      • 数据库设置
      • IT_DataBase.db

这是flaskapp.wsgi中的配置

#!/usr/bin/python                                                                
activate_this = '/var/www/FlaskApp/FlaskApp/venv/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))

import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/FlaskApp/")

from FlaskApp import app as application
application.secret_key = 'super_secret_key!'

这是apache的FlaskApp.conf

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

(编辑)我在尝试运行python flaskapp.wsgi时出现相同的错误

python apache sqlite flask sqlalchemy
1个回答
0
投票

通过赋予www数据所有权并从数据库设置中删除几行来解决的问题

© www.soinside.com 2019 - 2024. All rights reserved.