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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/modwsgi/0ecac6e4-53ad-43ad-ab9e-b498775a3275n%40googlegroups.com.

Reply via email to