Python 应用程序和 Apache with wsgi
Python application and Apache with wgsi
我有一个与 html 网页相关的应用程序,使用命令行运行良好:
export FLASK_APP=db_website_management.py
[export FLASK_ENV=development]
flask run
现在我希望 wgsi 调用该应用程序以便将其与 Apache 一起使用,但我真的不知道该怎么做。我试过这个:
#!/usr/bin/python3
import sys
import logging
sys.path.append('/var/www/dbwebsite')
sys.path.append('/var/www/dbwebsite/dbwebsite')
import db_website_management as application
但它给了我一个错误:
[Fri Feb 19 10:50:40.914786 2021] [lbmethod_heartbeat:notice] [pid 222722] AH02282: No slotmem from mod_heartmonitor
[Fri Feb 19 10:50:40.916966 2021] [mpm_prefork:notice] [pid 222722] AH00163: Apache/2.4.6 (CentOS) mod_wsgi/4.7.1 Python/3.6 configured -- resuming normal operations
[Fri Feb 19 10:50:40.916991 2021] [core:notice] [pid 222722] AH00094: Command line: 'httpd'
[Fri Feb 19 10:50:44.980311 2021] [wsgi:error] [pid 29766] INFO:root:Connection to database FGVD_hg19 created.
[Fri Feb 19 10:50:44.986516 2021] [wsgi:error] [pid 29766] [client 157.27.74.238:52848] mod_wsgi (pid=29766): Exception occurred processing WSGI script '/var/www/dbwebsite/dbwebsite.wsgi'.
[Fri Feb 19 10:50:44.986571 2021] [wsgi:error] [pid 29766] [client 157.27.74.238:52848] TypeError: 'module' object is not callable.
文件夹结构:
dbwebsite.wsgi
dbwebsite/
--- db_website_management.py
--- other script
非常感谢。
丹妮丝
这是官方文档。 https://flask.palletsprojects.com/en/1.1.x/deploying/mod_wsgi/#creating-a-wsgi-file
在不知道您的应用程序是如何调用的情况下,我无法告诉您确切的正确行,但它应该类似于
from db_website_management import app as application
(假设您的应用名为 app
)而不是
import db_website_management as application
此外,您必须将 dbwebsite.wsgi
移动到 dbwebsite
文件夹,或者通过创建其中一个文件夹,从 dbwebsite
文件夹中创建一个 python 模块__init__.py
个文件,然后将导入路径相应地调整为 from dbwebsite.db_website_management import app as application
我有一个与 html 网页相关的应用程序,使用命令行运行良好:
export FLASK_APP=db_website_management.py
[export FLASK_ENV=development]
flask run
现在我希望 wgsi 调用该应用程序以便将其与 Apache 一起使用,但我真的不知道该怎么做。我试过这个:
#!/usr/bin/python3
import sys
import logging
sys.path.append('/var/www/dbwebsite')
sys.path.append('/var/www/dbwebsite/dbwebsite')
import db_website_management as application
但它给了我一个错误:
[Fri Feb 19 10:50:40.914786 2021] [lbmethod_heartbeat:notice] [pid 222722] AH02282: No slotmem from mod_heartmonitor
[Fri Feb 19 10:50:40.916966 2021] [mpm_prefork:notice] [pid 222722] AH00163: Apache/2.4.6 (CentOS) mod_wsgi/4.7.1 Python/3.6 configured -- resuming normal operations
[Fri Feb 19 10:50:40.916991 2021] [core:notice] [pid 222722] AH00094: Command line: 'httpd'
[Fri Feb 19 10:50:44.980311 2021] [wsgi:error] [pid 29766] INFO:root:Connection to database FGVD_hg19 created.
[Fri Feb 19 10:50:44.986516 2021] [wsgi:error] [pid 29766] [client 157.27.74.238:52848] mod_wsgi (pid=29766): Exception occurred processing WSGI script '/var/www/dbwebsite/dbwebsite.wsgi'.
[Fri Feb 19 10:50:44.986571 2021] [wsgi:error] [pid 29766] [client 157.27.74.238:52848] TypeError: 'module' object is not callable.
文件夹结构:
dbwebsite.wsgi
dbwebsite/
--- db_website_management.py
--- other script
非常感谢。 丹妮丝
这是官方文档。 https://flask.palletsprojects.com/en/1.1.x/deploying/mod_wsgi/#creating-a-wsgi-file
在不知道您的应用程序是如何调用的情况下,我无法告诉您确切的正确行,但它应该类似于
from db_website_management import app as application
(假设您的应用名为 app
)而不是
import db_website_management as application
此外,您必须将 dbwebsite.wsgi
移动到 dbwebsite
文件夹,或者通过创建其中一个文件夹,从 dbwebsite
文件夹中创建一个 python 模块__init__.py
个文件,然后将导入路径相应地调整为 from dbwebsite.db_website_management import app as application