gpt4 book ai didi

python - Django、WSGI 和 Apache 的语法错误

转载 作者:行者123 更新时间:2023-12-01 03:38:20 25 4
gpt4 key购买 nike

我在尝试使用 mod_wsgi 在 Apache 下运行 Django 站点时遇到奇怪的错误。我已经为此工作了几个小时,但毫无结果。

仅供引用:我也在使用 Mezzanine。

日志:

[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30] mod_wsgi (pid=15554): Target WSGI script '/opt/mysite/mysite/wsgi.py' cannot be loaded as Python module.
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30] mod_wsgi (pid=15554): Exception occurred processing WSGI script '/opt/mysite/mysite/wsgi.py'.
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30] Traceback (most recent call last):
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30] File "/opt/mysite/mysite/wsgi.py", line 12, in <module>
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30] from django.core.wsgi import get_wsgi_application
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30] File "/usr/lib/python2.6/site-packages/django/__init__.py", line 3, in <module>
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30] from django.utils.version import get_version
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30] File "/usr/lib/python2.6/site-packages/django/utils/version.py", line 7, in <module>
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30] from django.utils.lru_cache import lru_cache
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30] File "/usr/lib/python2.6/site-packages/django/utils/lru_cache.py", line 28
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30] fasttypes = {int, str, frozenset, type(None)},
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30] ^
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30] SyntaxError: invalid syntax

mysite 的 httpd.conf(服务器上还有其他)

# Redirects all HTTP traffic to HTTPS
<VirtualHost *:80>
#ServerName test-mysite
#ServerAlias test-mysite mysite.com mysite
ServerName mysite.com
ServerAlias mysite test-mysite.com test-mysite

DocumentRoot /opt/mysite

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

WSGIScriptAlias / /opt/mysite/mysite/wsgi.py

</VirtualHost>

WSGISocketPrefix /var/run/wsgi

<VirtualHost *:443>
#ServerName test-mysite.com
#ServerAlias test-mysite
ServerName mysite.com
ServerAlias mysite test-mysite.com test-mysite
ErrorLog /var/log/httpd/ssl_mysite_error_log
CustomLog /var/log/httpd/ssl_mysite_request_log \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
TransferLog /var/log/httpd/ssl_mysite_access_log
LogLevel warn

WSGIDaemonProcess mysite.com processes=2 threads=15 display-name=%{GROUP}
WSGIProcessGroup mysite.com

WSGIScriptAlias / /opt/mysite/mysite/wsgi.py

<Directory /opt/mysite/mysite>
Options +FollowSymLinks -Indexes
AllowOverride All
order allow,deny
allow from all
</Directory>

SSLEngine On
SSLProtocol all -SSLv2
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
SSLCertificateFile /etc/pki/tls/certs/othersite_com.crt
SSLCertificateKeyFile /etc/pki/tls/private/othersite.com.key
SSLCertificateChainFile /etc/pki/tls/certs/DigiCertCA.crt
</VirtualHost>

httpd -V 输出:

Server version: Apache/2.2.15 (Unix)
Server built: Jul 12 2016 07:03:49
Server's Module Magic Number: 20051115:25
Server loaded: APR 1.3.9, APR-Util 1.3.9
Compiled using: APR 1.3.9, APR-Util 1.3.9
Architecture: 64-bit
Server MPM: Prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=128
-D HTTPD_ROOT="/etc/httpd"
-D SUEXEC_BIN="/usr/sbin/suexec"
-D DEFAULT_PIDLOG="run/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="logs/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"

如何解决这个问题?

最佳答案

[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30]   File "/usr/lib/python2.6/site-packages/django/utils/lru_cache.py", line 28
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30] fasttypes = {int, str, frozenset, type(None)},
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30] ^
[Fri Oct 14 23:48:13 2016] [error] [client 128.187.3.30] SyntaxError: invalid syntax

Python 2.6 不支持 set 语法 {....}

您可以use a version of Django that supports Python 2.6但请确保它也支持 Mezzanine或者将您的 Python 安装更新到 2.7

关于python - Django、WSGI 和 Apache 的语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40055541/

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