gpt4 book ai didi

python - 启用 SSL 时 Django 模块(嵌套管理和嵌套内联)的 ImportError

转载 作者:太空宇宙 更新时间:2023-11-03 13:37:55 25 4
gpt4 key购买 nike

我在启用 SSL 的生产环境中遇到以下错误。

ssl_error_log:

[Wed Nov 18 11:14:16.303520 2015] [:error] [pid 14069] [remote 128.132.66.000:116] mod_wsgi (pid=14069): Target WSGI script '/apps/staging/wisdmepid/django_version/django_version/wsgi.py' cannot be loaded as Python module.[Wed Nov 18 11:14:16.303584 2015] [:error] [pid 14069] [remote 128.132.66.000:116] mod_wsgi (pid=14069): Exception occurred processing WSGI script '/apps/staging/wisdmepid/django_version/django_version/wsgi.py'.
[Wed Nov 18 11:14:16.303617 2015] [:error] [pid 14069] [remote 128.132.66.000:116] Traceback (most recent call last):
[Wed Nov 18 11:14:16.303641 2015] [:error] [pid 14069] [remote 128.132.66.000:116] File "/apps/staging/wisdmepid/django_version/django_version/wsgi.py", line 18, in <module>
[Wed Nov 18 11:14:16.303732 2015] [:error] [pid 14069] [remote 128.132.66.000:116] application = get_wsgi_application()[Wed Nov 18 11:14:16.303747 2015] [:error] [pid 14069] [remote 128.132.66.000:116] File "/apps/staging/wisdmepid/django_version/env/lib/python2.7/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
[Wed Nov 18 11:14:16.303805 2015] [:error] [pid 14069] [remote 128.132.66.000:116] django.setup()
[Wed Nov 18 11:14:16.303816 2015] [:error] [pid 14069] [remote 128.132.66.000:116] File "/apps/staging/wisdmepid/django_version/env/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
[Wed Nov 18 11:14:16.303861 2015] [:error] [pid 14069] [remote 128.132.66.000:116] apps.populate(settings.INSTALLED_APPS)
[Wed Nov 18 11:14:16.303870 2015] [:error] [pid 14069] [remote 128.132.66.000:116] File "/apps/staging/wisdmepid/django_version/env/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
[Wed Nov 18 11:14:16.304015 2015] [:error] [pid 14069] [remote 128.132.66.000:116] app_config = AppConfig.create(entry)
[Wed Nov 18 11:14:16.304031 2015] [:error] [pid 14069] [remote 128.132.66.000:116] File "/apps/staging/wisdmepid/django_version/env/lib/python2.7/site-packages/django/apps/config.py", line 86, in create[Wed Nov 18 11:14:16.304125 2015] [:error] [pid 14069] [remote 128.132.66.000:116] module = import_module(entry)
[Wed Nov 18 11:14:16.304136 2015] [:error] [pid 14069] [remote 128.132.66.000:116] File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
[Wed Nov 18 11:14:16.304199 2015] [:error] [pid 14069] [remote 128.132.66.000:116] __import__(name)
[Wed Nov 18 11:14:16.304225 2015] [:error] [pid 14069] [remote 128.132.66.000:116] ImportError: No module named nested_admin[Wed Nov 18 11:14:29.322753 2015] [:error] [pid 14068] [remote 128.132.66.000:104] mod_wsgi (pid=14068): Target WSGI script '/apps/staging/wisdmepid/django_version/django_version/wsgi.py' cannot be loaded as Python module.[Wed Nov 18 11:14:29.322819 2015] [:error] [pid 14068] [remote 128.132.66.000:104] mod_wsgi (pid=14068): Exception occurred processing WSGI script '/apps/staging/wisdmepid/django_version/django_version/wsgi.py'.[Wed Nov 18 11:14:29.322851 2015] [:error] [pid 14068] [remote 128.132.66.000:104] Traceback (most recent call last):
[Wed Nov 18 11:14:29.322873 2015] [:error] [pid 14068] [remote 128.132.66.000:104] File "/apps/staging/wisdmepid/django_version/django_version/wsgi.py", line 18, in <module>
[Wed Nov 18 11:14:29.322955 2015] [:error] [pid 14068] [remote 128.132.66.000:104] application = get_wsgi_application()[Wed Nov 18 11:14:29.322970 2015] [:error] [pid 14068] [remote 128.132.66.000:104] File "/apps/staging/wisdmepid/django_version/env/lib/python2.7/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
[Wed Nov 18 11:14:29.323024 2015] [:error] [pid 14068] [remote 128.132.66.000:104] django.setup()
[Wed Nov 18 11:14:29.323034 2015] [:error] [pid 14068] [remote 128.132.66.000:104] File "/apps/staging/wisdmepid/django_version/env/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
[Wed Nov 18 11:14:29.323096 2015] [:error] [pid 14068] [remote 128.132.66.000:104] apps.populate(settings.INSTALLED_APPS)[Wed Nov 18 11:14:29.323107 2015] [:error] [pid 14068] [remote 128.132.66.000:104] File "/apps/staging/wisdmepid/django_version/env/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
[Wed Nov 18 11:14:29.323251 2015] [:error] [pid 14068] [remote 128.132.66.000:104] app_config = AppConfig.create(entry)
[Wed Nov 18 11:14:29.323266 2015] [:error] [pid 14068] [remote 128.132.66.000:104] File "/apps/staging/wisdmepid/django_version/env/lib/python2.7/site-packages/django/apps/config.py", line 86, in create
[Wed Nov 18 11:14:29.323374 2015] [:error] [pid 14068] [remote 128.132.66.000:104] module = import_module(entry)[Wed Nov 18 11:14:29.323393 2015] [:error] [pid 14068] [remote 128.132.66.000:104] File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
[Wed Nov 18 11:14:29.323448 2015] [:error] [pid 14068] [remote 128.132.66.000:104] __import__(name)
[Wed Nov 18 11:14:29.323471 2015] [:error] [pid 14068] [remote 128.132.66.000:104] ImportError: No module named nested_admin

我已经安装了模块django-nested-admin .我在使用 django-nested-inline 时也遇到同样的错误而不是 django-nested-admin。知道出了什么问题吗?

在网站上我得到:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

该代码在我们的非 SSL 站点中完美运行。
我已经尝试过 this 中提到的解决方案和 this .没用。任何指针都将非常有帮助。谢谢。

这是我们的 apache 配置文件。这不是实际的,但原始配置与此一致。

<VirtualHost *:80>
ServerName bogus.example.com:80
ErrorLog logs/error_log
TransferLog logs/access_log
LogLevel warn

RewriteEngine On
RewriteRule ^/?sslsite/(.*) https://%{SERVER_NAME}/sslsite/$1 [R,L]


alias /static/notsslsite /apps/deployment/notsslsite/django_version/static
<Directory /apps/deployment/notsslsite/django_version/static>
Require all granted
</Directory>

<Directory /apps/deployment/notsslsite/django_version/django_version>
<Files wsgi.py>
Require all granted
</Files>
</Directory>

WSGIDaemonProcess notsslsite processes=2 python-path=/apps/deployment/notsslsite/django_version:/apps/deployment/notsslsite/django_version/env/lib/python2.7/site-packages
WSGIProcessGroup notsslsite
WSGIScriptAlias /notsslsite /apps/deployment/notsslsite/django_version/django_version/wsgi.py process-group=notsslsite

</VirtualHost>

<VirtualHost *:443>
ServerName bogus.example.com:443
ErrorLog logs/ssl_error_log
TransferLog logs/ssl_access_log
LogLevel warn
SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
SSLCertificateFile /etc/httpd/ssl/bogus.example.com.crt
SSLCertificateKeyFile /etc/httpd/ssl/bogus.example.com.key
SSLCertificateChainFile /etc/httpd/ssl/bogus_chain.pem


SetEnvIf User-Agent ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
CustomLog logs/ssl_request_log \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

alias /static/sslsite /apps/staging/sslsite/django_version/static
<Directory /apps/staging/sslsite/django_version/static>
Require all granted
</Directory>

<Directory /apps/staging/sslsite/django_version/django_version>
<Files wsgi.py>
Require all granted
</Files>
</Directory>

WSGIDaemonProcess sslsite processes=2 python-path=/apps/staging/sslsite/django_version:/apps/staging/sslsite/django_version/env/lib/python2.7/site-packages
WSGIProcessGroup sslsite
WSGIScriptAlias /sslsite /apps/staging/sslsite/django_version/django_version/wsgi.py process-group=sslsite

</VirtualHost>

最佳答案

这是来自非 ssl 配置的 WSGIDaemonProcess 设置

WSGIDaemonProcess notsslsite processes=2 python-path=/apps/deployment/notsslsite/django_version:/apps/deployment/notsslsite/django_version/env/lib/python2.7/site-packages

这里是ssl配置

WSGIDaemonProcess sslsite processes=2 python-path=/apps/staging/sslsite/django_version:/apps/staging/sslsite/django_version/env/lib/python2.7/site-packages

您对 ssl 和非 ssl 实例使用了不同的 python 路径,可能 nested_admin 没有安装在第二个实例中。这只是在您的 apache 设置中对 django 重要的区别。尝试在 ssl 站点上设置与非 ssl 相同的环境,并检查它是否有效。如果可以,请从 ssl 配置中在环境中安装适当的包。如果它不起作用,可能是您的虚拟环境已损坏,请尝试重新创建它。

关于python - 启用 SSL 时 Django 模块(嵌套管理和嵌套内联)的 ImportError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33869197/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com