0

Installed xampp on ubuntu-16.04. XAMPP root installation location: /opt/lampp

Python 2.7.12 Django 1.11 XAMPP 5.6.30

The wsgi.py settings: ```python

import os
import sys
import site

site.addsitedir('/opt/lampp/htdocs/dpcm/dpcm/lib/python2.7/site-packages')

sys.path.insert(0, '/opt/lampp/htdocs/dpcm')
sys.path.insert(1, '/opt/lampp/htdocs/dpcm/dpcm1')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dpcm1.settings")
os.environ.setdefault("PYTHON_EGG_CACHE", "/opt/lampp/htdocs/dpcm/.python-eggs")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

# if import ssl module, it will occur an error.
import ssl

```

/opt/lampp/apache2/conf/httpd.conf content:

Alias /bitnami/ "/opt/lampp/apache2/htdocs/"
Alias /bitnami "/opt/lampp/apache2/htdocs"

<Directory "/opt/lampp/apache2/htdocs">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

WSGIScriptAlias /dpcm/ /opt/lampp/htdocs/dpcm/dpcm1/wsgi.py

#WSGIDaemonProcess /dpcm/ python-path=/opt/lampp/htdocs/dpcm:/opt/lampp/htdocs/dpcm/dpcm/lib/python2.7/site-packages
#WSGIProcessGroup /dpcm/

WSGIPythonPath /opt/lampp/htdocs/dpcm
WSGIPythonHome /opt/lampp/htdocs/dpcm/dpcm/
<Directory /opt/lampp/htdocs/dpcm/dpcm1>
    <Files wsgi.py>
        Order deny,allow
        Require all granted
    </Files>
</Directory>

Alias /static/ /opt/lampp/htdocs/dpcm/static/
<Directory /opt/lampp/htdocs/dpcm/static>
   Order allow,deny
   Allow from all
</Directory>

if import ssl module in inactive-mode, it can be imported successfully. But if add 'import ssl' in wsgi.py or other django project file, there will report an error message:

[Thu Jun 01 10:54:13.272126 2017] [wsgi:error] [pid 5430] [client 10.0.2.15:41534] mod_wsgi (pid=5430): Target WSGI script '/opt/lampp/htdocs/dpcm/dpcm1/wsgi.py' cannot be loaded as Python module.
[Thu Jun 01 10:54:13.272176 2017] [wsgi:error] [pid 5430] [client 10.0.2.15:41534] mod_wsgi (pid=5430): Exception occurred processing WSGI script '/opt/lampp/htdocs/dpcm/dpcm1/wsgi.py'.
[Thu Jun 01 10:54:13.272207 2017] [wsgi:error] [pid 5430] [client 10.0.2.15:41534] Traceback (most recent call last):
[Thu Jun 01 10:54:13.272230 2017] [wsgi:error] [pid 5430] [client 10.0.2.15:41534]   File "/opt/lampp/htdocs/dpcm/dpcm1/wsgi.py", line 33, in <module>
[Thu Jun 01 10:54:13.272308 2017] [wsgi:error] [pid 5430] [client 10.0.2.15:41534]     import ssl
[Thu Jun 01 10:54:13.272320 2017] [wsgi:error] [pid 5430] [client 10.0.2.15:41534]   File "/usr/lib/python2.7/ssl.py", line 97, in <module>
[Thu Jun 01 10:54:13.276754 2017] [wsgi:error] [pid 5430] [client 10.0.2.15:41534]     import _ssl             # if we can't import it, let the error propagate
[Thu Jun 01 10:54:13.276826 2017] [wsgi:error] [pid 5430] [client 10.0.2.15:41534] ImportError: /opt/lampp/lib/libssl.so.1.0.0: version `OPENSSL_1.0.1' not found (required by /opt/lampp/htdocs/dpcm/dpcm/lib/python2.7/lib-dynload/_ssl.x86_64-linux-gnu.so)

In normal, it link the .so to /usr/lib, but it find in /opt/lampp/lib, so i think it is env variables issue. Add following code in shell script: lampp

LD_LIBRARY_PATH='/usr/lib'
export LD_LIBRARY_PATH

and comment code

# if test "$(osguess)" = "macosx"
# then
#     # Thanks to drosenbe! - oswald [3sep10]
#     if test -z $DYLD_LIBRARY_PATH
#     then
#   export DYLD_LIBRARY_PATH="$LIBRARY_PATH"
#     else
#   export DYLD_LIBRARY_PATH="$LIBRARY_PATH:$DYLD_LIBRARY_PATH"
#     fi
# else
#     # Thanks to drosenbe! - oswald [3sep10]
#     if test -z $LD_LIBRARY_PATH
#     then
#   export LD_LIBRARY_PATH="$LIBRARY_PATH"
#     else
#   export LD_LIBRARY_PATH="$LIBRARY_PATH:$LD_LIBRARY_PATH"
#     fi
# fi

This is useless, does anybody have the same problem as me?

Sinbad lo
  • 85
  • 1
  • 1
  • 6
  • Recommend you read http://modwsgi.readthedocs.io/en/develop/user-guides/virtual-environments.html for correct way of setting up mod_wsgi with Python virtual environments. You shouldn't be using ``python-path``. This is unrelated to your SSL issue though. – Graham Dumpleton Jun 01 '17 at 10:02

3 Answers3

1

Your Python distribution is compiled for a different SSL library than what your Apache distribution is using. The one loaded by Apache is taking precedence and causing Python to later fail.

In short, you cannot use that Apache distribution as it will be incompatible with any Apache module which embeds a language, such as Python, PHP, Perl etc, where the language runtime is using the system SSL libraries. Use the system Apache distribution instead.

Graham Dumpleton
  • 57,726
  • 6
  • 119
  • 134
  • yes you are right, i used apache2+mysql to serve my project, instead of xampp. It works well. Thanks very much. – Sinbad lo Jun 02 '17 at 03:15
0

Just after import

site.addsitedir('/opt/lapmpp/htdocs/dpcm/dpcm/lib/python2.7/site-packages')

Should it be /opt/lampp instead of /opt/lapmpp?

Please try this change.

Adeel Ahmad
  • 1,033
  • 1
  • 11
  • 24
Gurdyal
  • 161
  • 2
  • 2
  • 11
  • opps, still not work, i think that this issue is same to [question](https://stackoverflow.com/questions/37802196/libcrypto-so-1-0-0-version-openssl-1-0-1-not-found-during-shell-exec) – Sinbad lo Jun 01 '17 at 06:57
0

Please check this as well, it may be helpful . Why use sys.path.append(path) instead of sys.path.insert(1, path)?

Gurdyal
  • 161
  • 2
  • 2
  • 11