0

I'm trying deploy django with apache2.4 mod_wsgi on ubuntu,but i'm giving an error.

First install packages: sudo apt upgrade && sudo apt install virtualenv python-setuptools python3.6(from ppa) python3-pip python3.6-dev libapache2-mod-wsgi-py3 apache2 mysql-server

Ok, All install correctly. So, I create a folder project mkdir /mnt/g/development/matrix Create a virtualenv virtualenv --python=python3.6 env and activate Install django2.0 from pip pip install django - ok install and check

 which python

/mnt/g/development/matrix/env/bin/python

python -V

Python 3.6.3

So I create a vhost on apache

    <VirtualHost *:80>
        ServerName 127.0.0.50
        ServerAlias matrix.local

        DocumentRoot /mnt/g/development/matrix/framework

         Alias /static /mnt/g/development/matrix/framework/static
         Alias /media /mnt/g/development/matrix/framework/media

        <Directory /mnt/g/development/matrix/framework/framework>
                <Files wsgi.py>
                Require all granted
                </Files>
         </Directory>


        <Directory /mnt/g/development/matrix/framework/media/>
                Require all granted
         </Directory>

         <Directory /mnt/g/development/matrix/framework/static/>
                Require all granted
        </Directory>

WSGIDaemonProcess matrix processes=2 threads=5 display-name=%{GROUP} python-path=/mnt/g/development/matrix/framework/:/mnt/g/development/matrix/env/lib/python3.6/site-packages
WSGIProcessGroup matrix
WSGIScriptAlias / /mnt/g/development/matrix/framework/framework/wsgi.py

</VirtualHost>

So, I start apache and mysql server, but I give an error

(env) root@WILLIAM:/mnt/g/development/matrix# tail /var/log/apache2/error.log [Tue Jun 19 04:01:10.947533 2018] [:error] [pid 14811] [remote 127.0.0.1:28540] mod_wsgi (pid=14811): Target WSGI script '/mnt/g/development/matrix/framework/framework/wsgi.py' cannot be loaded as Python module. [Tue Jun 19 04:01:10.948034 2018] [:error] [pid 14811] [remote 127.0.0.1:28540] mod_wsgi (pid=14811): Exception occurred processing WSGI script '/mnt/g/development/matrix/framework/framework/wsgi.py'. [Tue Jun 19 04:01:10.948034 2018] [:error] [pid 14811] [remote 127.0.0.1:28540] Traceback (most recent call last): [Tue Jun 19 04:01:10.948034 2018] [:error] [pid 14811] [remote 127.0.0.1:28540] File "/mnt/g/development/matrix/framework/framework/wsgi.py", line 12, in [Tue Jun 19 04:01:10.948534 2018] [:error] [pid 14811] [remote 127.0.0.1:28540] from django.core.wsgi import get_wsgi_application [Tue Jun 19 04:01:10.948534 2018] [:error] [pid 14811] [remote 127.0.0.1:28540] File "/mnt/g/development/matrix/env/lib/python3.6/site-packages/django/init.py", line 1, in [Tue Jun 19 04:01:10.949034 2018] [:error] [pid 14811] [remote 127.0.0.1:28540] from django.utils.version import get_version [Tue Jun 19 04:01:10.949034 2018] [:error] [pid 14811] [remote 127.0.0.1:28540] File "/mnt/g/development/matrix/env/lib/python3.6/site-packages/django/utils/version.py", line 61, in [Tue Jun 19 04:01:10.949534 2018] [:error] [pid 14811] [remote 127.0.0.1:28540] @functools.lru_cache() [Tue Jun 19 04:01:10.949534 2018] [:error] [pid 14811] [remote 127.0.0.1:28540] AttributeError: 'module' object has no attribute 'lru_cache'

If I use the same code on Ubuntu 14.04 with Python3.4.5 default I'ts work. Where I'm wronging?

My WSGIDeamonProcesses path it's right?

Thanks

  • Your `mod_wsgi` may have been compiled for Python 3.4. See this question for building your own `mod_wsgi`: https://stackoverflow.com/questions/44914961/install-mod-wsgi-on-ubuntu-with-python-3-6-apache-2-4-and-django-1-11 – Selcuk Jun 19 '18 at 06:32
  • I try this and I've the same problem, I believe that my vhost config be wrong. But I not found any tutorial to correctly deploy setup for python3.6 and mod_wsgi – Ricardo Prado Jun 19 '18 at 07:03
  • I would question whether mod_wsgi for correct version of Python is installed as well. Check using http://modwsgi.readthedocs.io/en/develop/user-guides/checking-your-installation.html#python-installation-in-use – Graham Dumpleton Jun 20 '18 at 03:04
  • Also review http://modwsgi.readthedocs.io/en/develop/user-guides/virtual-environments.html for the correct way to configure mod_wsgi for a virtual environment. – Graham Dumpleton Jun 20 '18 at 03:04
  • thanks Graham! I solved uninstall libapache2-mod-wsgi-py3 and install from pip mod_wsgi inside virtualenv and copy path from mod_wsgi --config and past module path to vhost. – Ricardo Prado Jun 20 '18 at 07:13

0 Answers0