簡體   English   中英

504網關超時服務器未及時響應

[英]504 Gateway Time-out The server didn't respond in time

我使用虛擬機運行燒瓶應用程序“ sqtf”。 她使用127.0.0.1:5000在本地工作,但不適用於我的apache服務器。 我使用python3.6,apache2.4和mod_wsgi。 這是我的項目的簡化結構:

/var/www/squashPy/src/squash_test_filter/
                              /sqtf
                                  sqtf.wsgi
                                  __init__.py
                                  /static
                                  /templates
                              /venv

在apache上配置我的VirtualHost'sqtf.com.conf',然后在我的sqtf.wsgi(還配置我的virtualenv和/ etc / hosts)上配置服務器之后,該服務器會在www.sqtf.com上做出響應,但會在我的登錄頁面或其他任何位置進行響應, www.sqtf.com/auth/login'504網關超時服務器端口80。

在我的error.log中:

從守護進程'sqtf'讀取響應時超時:/var/www/squashPy/src/squash_test_filter/sqtf/sqtf.wsgi

我在DeamonProcess中添加了一個python-home。 增加超時不會更改任何內容。

我的sqtf.com.conf

<VirtualHost *:80>
     ServerName www.sqtf.com
     ServerAlias sqtf.com
     ErrorLog /var/www/squashPy/sqtf.com/logs/error.log
     CustomLog /var/www/squashPy/sqtf.com/logs/custom.log combined
     WSGIDaemonProcess sqtf python-home='var/www/squashPy/src/squash_test_filter/venv'
     WSGIProcessGroup sqtf
     WSGIApplicationGroup %{GLOBAL}
     WSGIScriptAlias / /var/www/..../sqtf/sqtf.wsgi
     Alias /static/ /var/wwww/..../sqtf/static
     <Directory /var/www/..../static>
          Require all granted
     </Directory>
<VirtualHost>

我的sqtf.wsgi

    activate_this='/var/www/..../venv/bin/activate_this.py'
    with open(activate_this) as file_:
            exec(file_.read(), dict(__file__=activate_this))
    import sys
    import logging
    sys.path.insert(0, "/var/www/squashPy/src/squash_test_filter/")
    from sqtf import app as application

我的/ etc / hosts的一部分:

    127.0.0.1 localhost
    127.0.1.1 ubuntu
    127.0.0.1 www.sqtf.com sqtf.com sqtf

    # etc ...

我的/ sqtf / init .py的一部分

    import ...



    def create_app(test_config=None):
        # create and configure the app

        app = Flask(__name__, instance_relative_config=True)
        api = Api(app)

        app.config.from_mapping(
            SECRET_KEY='dev',
            DATABASE=os.path.join(app.instance_path, 'sqtf.sqlite'),
        )

        if test_config is None:
            # load the instance config, if it exists, when not testing
            app.config.from_pyfile('config.py', silent=True)
        else:
            # load the test config if passed in
            app.config.from_mapping(test_config)

        # ensure the instance folder exists
        try:
            os.makedirs(app.instance_path)
        except OSError:
            pass
        db.init_app(app)
        return app

我解決了這個問題,例如,如果您使用燒瓶工廠,例如create_app,則需要通過以下方式將from sqtf import app as application更改from sqtf import app as application .wsgi中的這一行:

from sqtf import create_app
application=create_app()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM