Python Django应用程序在尝试通过Apache连接到数据库时挂起
我很难解决这个问题。我有一个Django应用程序运行在Ubuntu14.04服务器上(使用Apache2.4和Python3.4的mod_wsgi)。它通过pymssql连接到SQL Server 在开发过程中,该应用程序运行良好。我查询数据库,数据库返回预期结果 但是,在生产环境中(在Apache用户下),脚本挂起在进行数据库查询的确切位置。我的浏览器(Chrome或Firefox)显示一个旋转的轮子,只要浏览器窗口打开,它就会继续旋转 我的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
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的有故障的第三方扩展模块,这些模块在子解释器中无法工作,并且可能会因死锁或崩溃而失败
见: