Score:0

unable to find django error when running django app through apache2

ro flag

I am trying to get a django app running on a apache2 server both on a raspberry pi for a project of mine. The appache server is running but I can't pull up the web page as I just get an "Internal Server Error" //Log files

[Fri Apr 07 19:28:44.334749 2023] [wsgi:error] [pid 24119:tid 1965745152] [remote 192.168.50.249:54720] mod_wsgi (pid=24119): Failed to exec Python script file '/home/pi/greenhouse/greenhouse/wsgi.py'.
[Fri Apr 07 19:28:44.335018 2023] [wsgi:error] [pid 24119:tid 1965745152] [remote 192.168.50.249:54720] mod_wsgi (pid=24119): Exception occurred processing WSGI script '/home/pi/greenhouse/greenhouse/wsgi.py'.
[Fri Apr 07 19:28:44.335914 2023] [wsgi:error] [pid 24119:tid 1965745152] [remote 192.168.50.249:54720] Traceback (most recent call last):
[Fri Apr 07 19:28:44.336045 2023] [wsgi:error] [pid 24119:tid 1965745152] [remote 192.168.50.249:54720]   File "/home/pi/greenhouse/greenhouse/wsgi.py", line 12, in <module>
[Fri Apr 07 19:28:44.336068 2023] [wsgi:error] [pid 24119:tid 1965745152] [remote 192.168.50.249:54720]     from django.core.wsgi import get_wsgi_application
[Fri Apr 07 19:28:44.336139 2023] [wsgi:error] [pid 24119:tid 1965745152] [remote 192.168.50.249:54720] ModuleNotFoundError: No module named 'django'

My 000-default.conf file

<VirtualHost *:80>

    #ServerName www.example.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /static /home/pi/greenhouse/static
    <Directory /home/pi/greenhouse/static>
        Require all granted
    </Directory>

    <Directory /home/pi/greenhouse/greenhouse>
    <Files wsgi.py>
        Require all granted
    </Files>
    </Directory>
    
    WSGIDaemonProcess greenhouse python-path=/home/pi/greenhouse python-home=/home/pi/greenhouse/greenhouseenv
    WSGIProcessGroup greenhouse
    WSGIScriptAlias / /home/pi/greenhouse/greenhouse/wsgi.py
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

My wsgi.py file

"""
WSGI config for greenhouse project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/4.1/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'greenhouse.settings')

application = get_wsgi_application()

I have made sure that django is installed in the virtual environment and have tried a couple other things but to no avail.

Nikita Kipriyanov avatar
za flag
*django is installed in the virtual environment* — are you talking about Python's virtualenv?
907VigiL avatar
ro flag
Yes i made a virtualenv for this project
Nikita Kipriyanov avatar
za flag
Aren't you just missing the leading slash in `python-home` path of `WSGIDaemonProcess`?
907VigiL avatar
ro flag
Thank you for pointing that out, I was using an older verison of the conf file in this the version in rn does have that /.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.