1

I am getting a weird error while trying to run my Django site under Apache using mod_wsgi. I have been working on this for hours to no avail.

FYI: I am also using Mezzanine.

Log:

[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

httpd.conf for mysite (there are others on the server)

# 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 output:

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"

How do I fix this?

1 Answer 1

2
[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 doesn't support set syntax {....}

You may use a version of Django that supports Python 2.6 but make sure it also supports Mezzanine OR Update your Python installation to 2.7

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.