Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Django应用程序在尝试通过Apache连接到数据库时挂起_Python_Sql Server_Django_Apache_Pymssql - Fatal编程技术网

Python Django应用程序在尝试通过Apache连接到数据库时挂起

Python Django应用程序在尝试通过Apache连接到数据库时挂起,python,sql-server,django,apache,pymssql,Python,Sql Server,Django,Apache,Pymssql,我很难解决这个问题。我有一个Django应用程序运行在Ubuntu14.04服务器上(使用Apache2.4和Python3.4的mod_wsgi)。它通过pymssql连接到SQL Server 在开发过程中,该应用程序运行良好。我查询数据库,数据库返回预期结果 但是,在生产环境中(在Apache用户下),脚本挂起在进行数据库查询的确切位置。我的浏览器(Chrome或Firefox)显示一个旋转的轮子,只要浏览器窗口打开,它就会继续旋转 我的apache2.conf文件中有以下内容: Serv

我很难解决这个问题。我有一个Django应用程序运行在Ubuntu14.04服务器上(使用Apache2.4和Python3.4的mod_wsgi)。它通过pymssql连接到SQL Server

在开发过程中,该应用程序运行良好。我查询数据库,数据库返回预期结果

但是,在生产环境中(在Apache用户下),脚本挂起在进行数据库查询的确切位置。我的浏览器(Chrome或Firefox)显示一个旋转的轮子,只要浏览器窗口打开,它就会继续旋转

我的
apache2.conf
文件中有以下内容:

ServerName localhost
# WSGIDaemonProcess application
WSGIPythonPath /home/production_code/python3env/lib/python3.4/site-packages:/home/production_code/school
# WSGIProcessGroup application
WSGIScriptAlias / /home/production_code/school/school/wsgi.py
# Python virtualenv home
WSGIPythonHome /home/production_code/python3env
# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf
<VirtualHost *:80>    
        ServerAdmin *****@school.edu
        ServerName  localhost
        DocumentRoot /var/www/html

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        Alias /static/ /home/production_code/school/static/

        <Directory /home/production_code/school/>
            Require all granted
        </Directory>
        <Directory /home/production_code/school/>
            <Files wsgi.py>
                Require all granted
            </Files>
        </Directory>
        <Directory /home/production_code/school/static>
            Require all granted
        </Directory>
</VirtualHost>
在我的
站点已启用/000 default.conf
文件中:

ServerName localhost
# WSGIDaemonProcess application
WSGIPythonPath /home/production_code/python3env/lib/python3.4/site-packages:/home/production_code/school
# WSGIProcessGroup application
WSGIScriptAlias / /home/production_code/school/school/wsgi.py
# Python virtualenv home
WSGIPythonHome /home/production_code/python3env
# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf
<VirtualHost *:80>    
        ServerAdmin *****@school.edu
        ServerName  localhost
        DocumentRoot /var/www/html

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        Alias /static/ /home/production_code/school/static/

        <Directory /home/production_code/school/>
            Require all granted
        </Directory>
        <Directory /home/production_code/school/>
            <Files wsgi.py>
                Require all granted
            </Files>
        </Directory>
        <Directory /home/production_code/school/static>
            Require all granted
        </Directory>
</VirtualHost>

ServerAdmin******@school.edu
服务器名本地主机
DocumentRoot/var/www/html
ErrorLog${APACHE_LOG_DIR}/error.LOG
CustomLog${APACHE\u LOG\u DIR}/access.LOG组合
别名/静态//家庭/生产代码/学校/静态/
要求所有授权
要求所有授权
要求所有授权
有人知道这可能是什么原因,或者我如何排除故障吗?Apache错误日志和访问日志在这种情况下没有特别的帮助,因为请求的响应从未呈现。类似地,Django调试在这里也没有用处。

而不是:

# WSGIDaemonProcess application
WSGIPythonPath /home/production_code/python3env/lib/python3.4/site-packages:/home/production_code/school
# WSGIProcessGroup application
使用:

其中一个关键部分是
WSGIApplicationGroup
指令,它被设置为
%{GLOBAL}

这是为了绕过Python的有故障的第三方扩展模块,这些模块在子解释器中无法工作,并且可能会因死锁或崩溃而失败

见:

还建议您返回到使用守护程序模式。使用嵌入式模式通常不是一个好主意

    • 而不是:

      # WSGIDaemonProcess application
      WSGIPythonPath /home/production_code/python3env/lib/python3.4/site-packages:/home/production_code/school
      # WSGIProcessGroup application
      
      使用:

      其中一个关键部分是
      WSGIApplicationGroup
      指令,它被设置为
      %{GLOBAL}

      这是为了绕过Python的有故障的第三方扩展模块,这些模块在子解释器中无法工作,并且可能会因死锁或崩溃而失败

      见:

      还建议您返回到使用守护程序模式。使用嵌入式模式通常不是一个好主意


      应用程序对数据库的访问通常是通过另一个端口,而不是通过Apache。SQL Server地址在生产环境中是否配置正确?感谢您的回复,aldux。我正在使用freetds通过端口1433访问SQL Server。此设置与我的开发和生产环境相同,但我会在有机会时再次检查。应用程序对数据库的访问通常是通过另一个端口,而不是通过Apache。SQL Server地址在生产环境中是否配置正确?感谢您的回复,aldux。我正在使用freetds通过端口1433访问SQL Server。此设置与我的开发和生产环境相同,但我会在有机会时再次检查。太棒了!谢谢你,格雷厄姆!这就解决了问题。这些链接也非常有用。太棒了!谢谢你,格雷厄姆!这就解决了问题。这些链接也非常有用。