This is what I get: ls -lasd /home/pi/Andola 4 drwxr-xr-x 16 pi www-data 4096 nov 30 17:56 /home/pi/Andola
ls -lasd /home/pi/Andola/myDjangoEnv 4 drwxr-xr-x 5 pi pi 4096 nov 16 15:29 /home/pi/Andola/myDjangoEnv ls -lasd /home/pi/Andola/myDjangoEnv/lib/python3.8/site-packages/django* 4 drwxr-xr-x 19 pi pi 4096 nov 30 15:06 /home/pi/Andola/myDjangoEnv/lib/python3.8/site-packages/django 4 drwxr-xr-x 2 pi pi 4096 nov 17 18:24 /home/pi/Andola/myDjangoEnv/lib/python3.8/site-packages/django_allauth-0.42.0.dist-info 4 drwxr-xr-x 2 pi pi 4096 nov 17 11:35 /home/pi/Andola/myDjangoEnv/lib/python3.8/site-packages/django_appconf-1.0.4.dist-info 4 drwxr-xr-x 2 pi pi 4096 nov 17 18:15 /home/pi/Andola/myDjangoEnv/lib/python3.8/site-packages/django_crispy_forms-1.9.2.dist-info 4 drwxr-xr-x 2 pi pi 4096 nov 17 11:35 /home/pi/Andola/myDjangoEnv/lib/python3.8/site-packages/django_imagekit-4.0.2.dist-info 4 drwxr-xr-x 2 pi pi 4096 nov 16 16:42 /home/pi/Andola/myDjangoEnv/lib/python3.8/site-packages/django_phonenumber_field-4.0.0.dist-info 4 drwxr-xr-x 2 pi pi 4096 nov 17 18:10 /home/pi/Andola/myDjangoEnv/lib/python3.8/site-packages/django_tinymce-3.1.0.dist-info 4 drwxr-xr-x 2 pi pi 4096 nov 17 18:17 /home/pi/Andola/myDjangoEnv/lib/python3.8/site-packages/django_widget_tweaks-1.4.8.dist-info My virtual environment has python 3.8 as that's the one my application needs, however I think wsgi seems to be pulling python 3.7 out of somewhere. How do I now whether I'm using the wrong version of wsgi and what can I do to switch for the right one?? I've been searching some tutorials but haven't had any success I installed wsgi using this command while my virtual environment was activated: sudo apt-get install libapache2-mod-wsgi-py3 Thnk you for your help El lunes, 30 de noviembre de 2020 a la(s) 21:26:22 UTC-6, Graham Dumpleton escribió: > Two possibility come to mind immediately. > > The first is that the version of Python that mod_wsgi was compiled for is > different to the version of Python your virtual environment was created > using. You can't force mod_wsgi compiled for one Python version to use a > virtual environment for a different Python version. > > The second is that the permissions on the Python virtual environment root > directory are such that the Apache user cannot access it, or that the > Django package directory within the site-packages directory of the Python > virtual environment doesn't have permissions such that Apache user can > access it. > > What do you get for: > > ls -lasd /home/pi/Andola > ls -lasd /home/pi/Andola/myDjangoEnv > ls -lasd > /home/pi/Andola/myDjangoEnv/lib/python3.7/site-packages/django* > > Graham > > On 1 Dec 2020, at 2:16 pm, Anibal Xochipa <aniba...@gmail.com> wrote: > > I'm trying to deploy my Django app using Apache2 on a raspberry pi 4B > running raspbian 10 > My project path looks like this > /home/pi/Andola > Inside that folder I created a Virtual environment called MyDjangoEnv > running python 3.8.2 and Django 3.0.3 so the path to the virtual > environment looks like this > /home/pi/Andola/myDjangoEnv > My wsgi.py file lives inside this folder: /home/pi/Andola/AnDjo/wsgi.py , > next to the settings.py , __init__.py , etc > > > I copied the file 000-default.conf on /etc/apache2/sites-available to > another one named django_project.conf in order to configure my own site. I > configured it according to Django documentation and my new file looks like > this: > > <VirtualHost *:80> > # The ServerName directive sets the request scheme, hostname and port that > # the server uses to identify itself. This is used when creating > # redirection URLs. In the context of virtual hosts, the ServerName > # specifies what hostname must appear in the request's Host: header to > # match this virtual host. For the default virtual host (this file) this > # value is not decisive as it is used as a last resort host regardless. > # However, you must set it for any further virtual host explicitly. > #ServerName www.example.com > > ServerAdmin webmaster@localhost > DocumentRoot /var/www/html > > # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, > # error, crit, alert, emerg. > # It is also possible to configure the loglevel for particular > # modules, e.g. > #LogLevel info ssl:warn > > ErrorLog ${APACHE_LOG_DIR}/error.log > CustomLog ${APACHE_LOG_DIR}/access.log combined > > # For most configuration files from conf-available/, which are > # enabled or disabled at a global level, it is possible to > # include a line for only one particular virtual host. For example the > # following line enables the CGI configuration for this host only > # after it has been globally disabled with "a2disconf". > #Include conf-available/serve-cgi-bin.conf > > Alias /static /home/pi/Andola/static > <Directory /home/pi/Andola/static> > Require all granted > </Directory> > > Alias /media /home/pi/Andola/media > <Directory /home/pi/Andola/media> > Require all granted > </Directory> > > <Directory /home/pi/Andola/AnDjo> > <Files wsgi.py> > Require all granted > </Files> > </Directory> > > WSGIScriptAlias / /home/pi/Andola/AnDjo/wsgi.py > WSGIDaemonProcess django_app python-path=/home/pi/Andola/ > python-home=/home/pi/Andola/myDjangoEnv > WSGIProcessGroup django_app > > </VirtualHost> > > # vim: syntax=apache ts=4 sw=4 sts=4 sr noet > > I think I gave the propper permissions to media folder and changed the > ownership of my project folder (Andola) to www-data. > > My Django application runs totally fine when I use python manage.py > runserver but whenever I try to run apache it gives me the 500 Internal > Server Error and the next shows up in the error log > > [Mon Nov 30 20:47:16.396524 2020] [mpm_event:notice] [pid 10724:tid > 3069383184] AH00491: caught SIGTERM, shutting down > [Mon Nov 30 20:47:16.540219 2020] [mpm_event:notice] [pid 12812:tid > 3069309456] AH00489: Apache/2.4.38 (Raspbian) mod_wsgi/4.6.5 Python/3.7 > configured -- resuming normal operations > [Mon Nov 30 20:47:16.540623 2020] [core:notice] [pid 12812:tid 3069309456] > AH00094: Command line: '/usr/sbin/apache2' > [Mon Nov 30 20:47:20.764437 2020] [wsgi:error] [pid 12813:tid 3038991392] > [remote ::1:52238] mod_wsgi (pid=12813): Failed to exec Python script file > '/home/pi/Andola/AnDjo/wsgi.py'. > [Mon Nov 30 20:47:20.764696 2020] [wsgi:error] [pid 12813:tid 3038991392] > [remote ::1:52238] mod_wsgi (pid=12813): Exception occurred processing WSGI > script '/home/pi/Andola/AnDjo/wsgi.py'. > [Mon Nov 30 20:47:20.765543 2020] [wsgi:error] [pid 12813:tid 3038991392] > [remote ::1:52238] Traceback (most recent call last): > [Mon Nov 30 20:47:20.767301 2020] [wsgi:error] [pid 12813:tid 3038991392] > [remote ::1:52238] File "/home/pi/Andola/AnDjo/wsgi.py", line 12, in > <module> > [Mon Nov 30 20:47:20.767372 2020] [wsgi:error] [pid 12813:tid 3038991392] > [remote ::1:52238] from django.core.wsgi import get_wsgi_application > [Mon Nov 30 20:47:20.767491 2020] [wsgi:error] [pid 12813:tid 3038991392] > [remote ::1:52238] ModuleNotFoundError: No module named 'django' > > I ran the scripts here > https://modwsgi.readthedocs.io/en/develop/user-guides/checking-your-installation.html > getting > the next results: > > Python Installation in use: > sys.version = '3.7.3 (default, Jul 25 2020, 13:03:44) \n[GCC 8.3.0]' > sys.prefix = '/home/pi/Andola/myDjangoEnv' > > Python module search path: > sys.path = ['/home/pi/Andola', '/usr/lib/python37.zip', > '/usr/lib/python3.7', '/usr/lib/python3.7/lib-dynload'] > > Embedded or Daemon Mode > mod_wsgi.process_group = 'django_app' > > Subinterpreter Being Used > mod_wsgi.application_group = '192.168.1.70|' > > I can see that wsgi might not be using myDjangoEnv and a bad configuration > is happening but as this is the first time I'm using wsgi and also the > first time trying to make a website I've been kind of lost for the last few > days /:: > > -- > You received this message because you are subscribed to the Google Groups > "modwsgi" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to modwsgi+u...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/modwsgi/0ecac6e4-53ad-43ad-ab9e-b498775a3275n%40googlegroups.com > > <https://groups.google.com/d/msgid/modwsgi/0ecac6e4-53ad-43ad-ab9e-b498775a3275n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > > -- You received this message because you are subscribed to the Google Groups "modwsgi" group. To unsubscribe from this group and stop receiving emails from it, send an email to modwsgi+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/modwsgi/f34e15a9-1913-4fb4-bdbc-3e54c4ef3640n%40googlegroups.com.