You still aren't telling mod_wsgi the correct location of your Django project
as I mentioned you possibly needed to in last mail.
If using embedded mode, use:
WSGIPythonPath /opt/hawmusarchive
If using daemon mode add the python-path option to WSGIDaemonProcess directive.
WSGIDaemonProcess hawmusarchive python-path=/opt/hawmusarchive
The project directory is the one with the wsgi.py file in. So the parent of
that, which works out to be /opt/hawmusarchive and not /opt/.
Graham
> On 22 Aug 2019, at 11:33 am, Bob Bobsled <[email protected]> wrote:
>
> Hi Graham,
> Thank you for your reply and info. Sorry about the excerpted errorlog, but I
> wasn't noticing anything useful until it gets down to the mod_wsig bits.
> Complete one is listed below.
>
> I also adjusted the conf.d to use daemon mode and changed the PythonPath but
> still getting the 500 internal server error. Still a bit stuck on what to
> try next. That "Failed to exec Python script file
> '/opt/hawmusarchive/hawmusarchive/wsgi.py" from the error log seems like it
> might be something going wrong.
>
> Bests,
> Bob
>
>
>
> [Wed Aug 21 13:19:46.042005 2019] [suexec:notice] [pid 25703:tid
> 139925794353472] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
> [Wed Aug 21 13:19:46.054797 2019] [so:warn] [pid 25703:tid 139925794353472]
> AH01574: module wsgi_module is already loaded, skipping
> AH00558: httpd: Could not reliably determine the server's fully qualified
> domain name, using localhost.localdomain. Set the 'ServerName' directive
> globally to suppress this message
> [Wed Aug 21 13:19:46.056618 2019] [lbmethod_heartbeat:notice] [pid 25703:tid
> 139925794353472] AH02282: No slotmem from mod_heartmonitor
> [Wed Aug 21 13:19:46.057001 2019] [http2:warn] [pid 25703:tid
> 139925794353472] AH02951: mod_ssl does not seem to be enabled
> [Wed Aug 21 13:19:46.059222 2019] [mpm_event:notice] [pid 25703:tid
> 139925794353472] AH00489: Apache/2.4.39 (Fedora) mod_wsgi/4.6.4 Python/3.7
> configured -- resuming normal operations
> [Wed Aug 21 13:19:46.059241 2019] [core:notice] [pid 25703:tid
> 139925794353472] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
> [Wed Aug 21 13:19:50.256302 2019] [wsgi:error] [pid 25707:tid
> 139925702158080] [remote 128.171.51.150:57114 <http://128.171.51.150:57114/>]
> mod_wsgi (pid=25707): Failed to exec Python script file
> '/opt/hawmusarchive/hawmusarchive/wsgi.py'.
> [Wed Aug 21 13:19:50.256366 2019] [wsgi:error] [pid 25707:tid
> 139925702158080] [remote 128.171.51.150:57114 <http://128.171.51.150:57114/>]
> mod_wsgi (pid=25707): Exception occurred processing WSGI script
> '/opt/hawmusarchive/hawmusarchive/wsgi.py'.
> [Wed Aug 21 13:19:50.256937 2019] [wsgi:error] [pid 25707:tid
> 139925702158080] [remote 128.171.51.150:57114 <http://128.171.51.150:57114/>]
> Traceback (most recent call last):
> [Wed Aug 21 13:19:50.257005 2019] [wsgi:error] [pid 25707:tid
> 139925702158080] [remote 128.171.51.150:57114 <http://128.171.51.150:57114/>]
> File "/opt/hawmusarchive/hawmusarchive/wsgi.py", line 16, in <module>
> [Wed Aug 21 13:19:50.257015 2019] [wsgi:error] [pid 25707:tid
> 139925702158080] [remote 128.171.51.150:57114 <http://128.171.51.150:57114/>]
> application = get_wsgi_application()
> [Wed Aug 21 13:19:50.257023 2019] [wsgi:error] [pid 25707:tid
> 139925702158080] [remote 128.171.51.150:57114 <http://128.171.51.150:57114/>]
> File "/usr/lib/python3.7/site-packages/django/core/wsgi.py", line 12, in
> get_wsgi_application
> [Wed Aug 21 13:19:50.257028 2019] [wsgi:error] [pid 25707:tid
> 139925702158080] [remote 128.171.51.150:57114 <http://128.171.51.150:57114/>]
> django.setup(set_prefix=False)
> [Wed Aug 21 13:19:50.257035 2019] [wsgi:error] [pid 25707:tid
> 139925702158080] [remote 128.171.51.150:57114 <http://128.171.51.150:57114/>]
> File "/usr/lib/python3.7/site-packages/django/__init__.py", line 19, in
> setup
> [Wed Aug 21 13:19:50.257060 2019] [wsgi:error] [pid 25707:tid
> 139925702158080] [remote 128.171.51.150:57114 <http://128.171.51.150:57114/>]
> configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
> [Wed Aug 21 13:19:50.257067 2019] [wsgi:error] [pid 25707:tid
> 139925702158080] [remote 128.171.51.150:57114 <http://128.171.51.150:57114/>]
> File "/usr/lib/python3.7/site-packages/django/conf/__init__.py", line 57,
> in __getattr__
> [Wed Aug 21 13:19:50.257071 2019] [wsgi:error] [pid 25707:tid
> 139925702158080] [remote 128.171.51.150:57114 <http://128.171.51.150:57114/>]
> self._setup(name)
> [Wed Aug 21 13:19:50.257078 2019] [wsgi:error] [pid 25707:tid
> 139925702158080] [remote 128.171.51.150:57114 <http://128.171.51.150:57114/>]
> File "/usr/lib/python3.7/site-packages/django/conf/__init__.py", line 44,
> in _setup
> [Wed Aug 21 13:19:50.257082 2019] [wsgi:error] [pid 25707:tid
> 139925702158080] [remote 128.171.51.150:57114 <http://128.171.51.150:57114/>]
> self._wrapped = Settings(settings_module)
> [Wed Aug 21 13:19:50.257089 2019] [wsgi:error] [pid 25707:tid
> 139925702158080] [remote 128.171.51.150:57114 <http://128.171.51.150:57114/>]
> File "/usr/lib/python3.7/site-packages/django/conf/__init__.py", line 107,
> in __init__
> [Wed Aug 21 13:19:50.257103 2019] [wsgi:error] [pid 25707:tid
> 139925702158080] [remote 128.171.51.150:57114 <http://128.171.51.150:57114/>]
> mod = importlib.import_module(self.SETTINGS_MODULE)
> [Wed Aug 21 13:19:50.257109 2019] [wsgi:error] [pid 25707:tid
> 139925702158080] [remote 128.171.51.150:57114 <http://128.171.51.150:57114/>]
> File "/usr/lib64/python3.7/importlib/__init__.py", line 127, in
> import_module
> [Wed Aug 21 13:19:50.257114 2019] [wsgi:error] [pid 25707:tid
> 139925702158080] [remote 128.171.51.150:57114 <http://128.171.51.150:57114/>]
> return _bootstrap._gcd_import(name[level:], package, level)
> [Wed Aug 21 13:19:50.257120 2019] [wsgi:error] [pid 25707:tid
> 139925702158080] [remote 128.171.51.150:57114 <http://128.171.51.150:57114/>]
> File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
> [Wed Aug 21 13:19:50.257141 2019] [wsgi:error] [pid 25707:tid
> 139925702158080] [remote 128.171.51.150:57114 <http://128.171.51.150:57114/>]
> File "<frozen importlib._bootstrap>", line 983, in _find_and_load
> [Wed Aug 21 13:19:50.257148 2019] [wsgi:error] [pid 25707:tid
> 139925702158080] [remote 128.171.51.150:57114 <http://128.171.51.150:57114/>]
> File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
> [Wed Aug 21 13:19:50.257165 2019] [wsgi:error] [pid 25707:tid
> 139925702158080] [remote 128.171.51.150:57114 <http://128.171.51.150:57114/>]
> ModuleNotFoundError: No module named 'hawmusarchive.settings'
>
> -----------------
>
> # httpd conf.d file for django.
> # httpd.conf calls all conf.d files.
>
> LoadModule wsgi_module
> "/usr/lib64/python3.7/site-packages/mod_wsgi/server/mod_wsgi-py37.cpython-37m-x86_64-linux-gnu.so
> <http://mod_wsgi-py37.cpython-37m-x86_64-linux-gnu.so/>"
> WSGIPythonHome "/usr"
> ##DAEMON MODE
> WSGIDaemonProcess hawmusarchive python-path="/opt"
> WSGIProcessGroup hawmusarchive
> <Directory "/opt/hawmusarchive/">
> Require all granted
> </Directory>
> #----------------------------------------------------
> #----------------------------------------------------
> ## VIRTUAL HOSTS
> #----------------------------------------------------
> #----------------------------------------------------
> <VirtualHost *:80>
> ServerName hawmusarchive.128.171.51.150.nip.io
> <http://hawmusarchive.128.171.51.150.nip.io/>
> ServerAlias hawmusarchive.128.171.51.150.nip.io
> <http://hawmusarchive.128.171.51.150.nip.io/>
> DocumentRoot /var/www/html
> <Directory /opt/hawmusarchive>
> Options +Indexes +Includes +FollowSymLinks +MultiViews
> AllowOverride All
> Require all granted
> </Directory>
> WSGIScriptAlias / "/opt/hawmusarchive/hawmusarchive/wsgi.py"
> <Directory "/opt/hawmusarchive/hawmusarchive">
> <Files wsgi.py>
> Require all granted
> </Files>
> </Directory>
> Alias /robots.txt /opt/hawmusarchive/static/robots.txt
> Alias /favicon.ico /opt/hawmusarchive/static/favicon.ico
>
> Alias /media/ /opt/hawmusarchive/media/
> Alias /static/ /opt/hawmusarchive/static/
> <Directory /opt/hawmusarchive/static>
> Require all granted
> </Directory>
>
> <Directory /opt/hawmusarchive/media>
> Require all granted
> </Directory>
>
> </VirtualHost>
>
> On Tue, Aug 20, 2019 at 2:35 PM Graham Dumpleton <[email protected]
> <mailto:[email protected]>> wrote:
> BTW, you shouldn't be setting:
>
> WSGIPythonPath
> "/usr/lib64/python3.7:/usr/lib64/python3.7/lib-dynload:/usr/lib64/python3.7/site-packages"
>
> You do not need to include default locations.
>
> What you should be setting WSGIPythonPath to is the parent directory of where
> your Python project is. See the Django docs:
>
> https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/modwsgi/
> <https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/modwsgi/>
>
> You should also look at using daemon mode of mod_wsgi. It is the recommended
> deployment method.
>
>> On 21 Aug 2019, at 10:24 am, Graham Dumpleton <[email protected]
>> <mailto:[email protected]>> wrote:
>>
>> You don't actually show the exception details in the log that I can see. You
>> truncated it. It is the bit at the end of the traceback which is important
>> as that says what the exception is.
>>
>>> On 21 Aug 2019, at 10:20 am, Bob Bobsled <[email protected]
>>> <mailto:[email protected]>> wrote:
>>>
>>> Hi,
>>> I'm struggling badly with mod_wsgi, python3, and django on fedora30. Seems
>>> like everything is working alone, but I cannot get mod_wsgi to work with
>>> django, if that makes any sense. In other words my django app works from
>>> runserver, and I can see the whiskey image from mod_wsgi, and can serve a
>>> simple python script with mod_wsgi, but cannot get the django production
>>> server approach working for my app using mod_wsgi with httpd (apache).
>>>
>>> I've put my app (hawmusarchive) in several places to test such as
>>> /opt/hawmusarchive, or /var/www/hawmusarchive, or
>>> /var/www/html/hawmusarchive but all seem to get the internal server error
>>> so am appending httpd server log below which is showing issues with
>>> wsgi.py. I've checked permissions/ownership (777, apache:apache) on
>>> everything.
>>>
>>> I'm not using venev, and am wondering if django being in
>>> /usr/lib/python3.7/site-packages (32bit), and mod_wsgi installed in
>>> /usr/lib64/python3.7/site-packages (64 bit) is confusing it for some reason?
>>>
>>> I've worked thru my config.d file for wsgi alias, vhost carefully, and list
>>> it way below if somehow I buggered it to provoke the internal server error.
>>>
>>> Any help/hints very greatly appreciated on perhaps where to keep looking.
>>>
>>> Regards,
>>> bob
>>>
>>> EXCERPT from /var/log/httpd/error_logs:
>>>
>>> [Mon Aug 19 15:00:13.855666 2019] [mpm_event:notice] [pid 5992:tid
>>> 140091650494784] AH00489: Apache/2.4.39 (Fedora) mod_wsgi/4.6.4 Python/3.7
>>> configured -- resuming normal operations
>>> [Mon Aug 19 15:00:13.855688 2019] [core:notice] [pid 5992:tid
>>> 140091650494784] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
>>> [Mon Aug 19 15:00:18.768792 2019] [wsgi:error] [pid 5997:tid
>>> 140091162883840] [client 128.171.51.150:41152
>>> <http://128.171.51.150:41152/>] mod_wsgi (pid=5997): Failed to exec Python
>>> script file '/opt/hawmusarchive/hawmusarchive/wsgi.py'.
>>> [Mon Aug 19 15:00:18.768873 2019] [wsgi:error] [pid 5997:tid
>>> 140091162883840] [client 128.171.51.150:41152
>>> <http://128.171.51.150:41152/>] mod_wsgi (pid=5997): Exception occurred
>>> processing WSGI script '/opt/hawmusarchive/hawmusarchive/wsgi.py'.
>>> [Mon Aug 19 15:00:18.769468 2019] [wsgi:error] [pid 5997:tid
>>> 140091162883840] [client 128.171.51.150:41152
>>> <http://128.171.51.150:41152/>] Traceback (most recent call last):
>>> [Mon Aug 19 15:00:18.769557 2019] [wsgi:error] [pid 5997:tid
>>> 140091162883840] [client 128.171.51.150:41152
>>> <http://128.171.51.150:41152/>] File
>>> "/opt/hawmusarchive/hawmusarchive/wsgi.py", line 16, in <module>
>>> [Mon Aug 19 15:00:18.769566 2019] [wsgi:error] [pid 5997:tid
>>> 140091162883840] [client 128.171.51.150:41152
>>> <http://128.171.51.150:41152/>] application = get_wsgi_application()
>>> [Mon Aug 19 15:00:18.769575 2019] [wsgi:error] [pid 5997:tid
>>> 140091162883840] [client 128.171.51.150:41152
>>> <http://128.171.51.150:41152/>] File
>>> "/usr/lib/python3.7/site-packages/django/core/wsgi.py", line 12, in
>>> get_wsgi_application
>>> [Mon Aug 19 15:00:18.769613 2019] [wsgi:error] [pid 5997:tid
>>> 140091162883840] [client 128.171.51.150:41152
>>> <http://128.171.51.150:41152/>] django.setup(set_prefix=False)
>>> [Mon Aug 19 15:00:18.769621 2019] [wsgi:error] [pid 5997:tid
>>> 140091162883840] [client 128.171.51.150:41152
>>> <http://128.171.51.150:41152/>] File
>>> "/usr/lib/python3.7/site-packages/django/__init__.py", line 19, in setup
>>> [Mon Aug 19 15:00:18.769626 2019] [wsgi:error] [pid 5997:tid
>>> 140091162883840] [client 128.171.51.150:41152
>>> <http://128.171.51.150:41152/>]
>>> configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
>>> [Mon Aug 19 15:00:18.769633 2019] [wsgi:error] [pid 5997:tid
>>> 140091162883840] [client 128.171.51.150:41152
>>> <http://128.171.51.150:41152/>] File
>>> "/usr/lib/python3.7/site-packages/django/conf/__init__.py", line 57, in
>>> __getattr__
>>> [Mon Aug 19 15:00:18.769637 2019] [wsgi:error] [pid 5997:tid
>>> 140091162883840] [client 128.171.51.150:41152
>>> <http://128.171.51.150:41152/>] self._setup(name)
>>> [Mon Aug 19 15:00:18.769650 2019] [wsgi:error] [pid 5997:tid
>>> 140091162883840] [client 128.171.51.150:41152
>>> <http://128.171.51.150:41152/>] File
>>> "/usr/lib/python3.7/site-packages/django/conf/__init__.py", line 44, in
>>> _setup
>>> [Mon Aug 19 15:00:18.769656 2019] [wsgi:error] [pid 5997:tid
>>> 140091162883840] [client 128.171.51.150:41152
>>> <http://128.171.51.150:41152/>] self._wrapped =
>>> Settings(settings_module)
>>> [Mon Aug 19 15:00:18.769673 2019] [wsgi:error] [pid 5997:tid
>>> 140091162883840] [client 128.171.51.150:41152
>>> <http://128.171.51.150:41152/>] File
>>> "/usr/lib/python3.7/site-packages/django/conf/__init__.py", line 107, in
>>> __init__
>>> [Mon Aug 19 15:00:18.769677 2019] [wsgi:error] [pid 5997:tid
>>> 140091162883840] [client 128.171.51.150:41152
>>> <http://128.171.51.150:41152/>] mod =
>>> importlib.import_module(self.SETTINGS_MODULE)
>>> [Mon Aug 19 15:00:18.769684 2019] [wsgi:error] [pid 5997:tid
>>> 140091162883840] [client 128.171.51.150:41152
>>> <http://128.171.51.150:41152/>] File
>>> "/usr/lib64/python3.7/importlib/__init__.py", line 127, in import_module
>>>
>>> ---------------
>>>
>>>
>>> # httpd conf.d file for django.
>>> # httpd.conf calls all conf.d files.
>>>
>>> ##LOAD MODULE
>>> #this one was the system dnf install mod_wsgi-, from mod_wsgi-express-3
>>> LoadModule wsgi_module
>>> "/usr/lib64/python3.7/site-packages/mod_wsgi/server/mod_wsgi-py37.cpython-37m-x86_64-linux-gnu.so
>>> <http://mod_wsgi-py37.cpython-37m-x86_64-linux-gnu.so/>"
>>>
>>> #this is the actual apache module location:
>>> #LoadModule wsgi_module "/etc/httpd/modules/mod_wsgi_python3.so"
>>>
>>> WSGIPythonHome "/usr" #pyhon3 is under /usr/lib/python3.7 etc.
>>> WSGIPythonPath
>>> "/usr/lib64/python3.7:/usr/lib64/python3.7/lib-dynload:/usr/lib64/python3.7/site-packages"
>>>
>>> <Directory "/opt/hawmusarchive/">
>>> Require all granted
>>> </Directory>
>>>
>>> #----------------------------------------------------
>>> #----------------------------------------------------
>>> ## VIRTUAL HOST
>>> #----------------------------------------------------
>>> #----------------------------------------------------
>>> <VirtualHost *:80>
>>> ServerName hawmusarchive.128.171.51.150.nip.io
>>> <http://hawmusarchive.128.171.51.150.nip.io/>
>>> ServerAlias hawmusarchive.128.171.51.150.nip.io
>>> <http://hawmusarchive.128.171.51.150.nip.io/>
>>> DocumentRoot /var/www/html
>>> <Directory /opt/hawmusarchive>
>>> Options +Indexes +Includes +FollowSymLinks +MultiViews
>>> AllowOverride All
>>> Require all granted
>>> </Directory>
>>> #WSGIScriptAlias / "/var/www/html/hawmusarchive/hawmusarchive/wsgi.py"
>>> process-group=hawmusarchive
>>> WSGIScriptAlias / "/opt/hawmusarchive/hawmusarchive/wsgi.py"
>>> <Directory "/opt/hawmusarchive/hawmusarchive">
>>> <Files wsgi.py>
>>> Require all granted
>>> </Files>
>>> </Directory>
>>> Alias /robots.txt /opt/hawmusarchive/static/robots.txt
>>> Alias /favicon.ico /opt/hawmusarchive/static/favicon.ico
>>>
>>> Alias /media/ /opt/hawmusarchive/media/
>>> Alias /static/ /opt/hawmusarchive/static/
>>>
>>> <Directory /opt/hawmusarchive/static>
>>> Require all granted
>>> </Directory>
>>>
>>> <Directory /opt/hawmusarchive/media>
>>> Require all granted
>>> </Directory>
>>>
>>> </VirtualHost>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> --
>>> 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 [email protected]
>>> <mailto:[email protected]>.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/modwsgi/CALWZDaMkOBP0eVLhxq7_jZi%2BmLi9nQBQh_taofMzAE9x7A1YRQ%40mail.gmail.com
>>>
>>> <https://groups.google.com/d/msgid/modwsgi/CALWZDaMkOBP0eVLhxq7_jZi%2BmLi9nQBQh_taofMzAE9x7A1YRQ%40mail.gmail.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 [email protected]
> <mailto:[email protected]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/modwsgi/7BF16480-8D58-4B6A-AE8E-D8F10668A4AF%40gmail.com
>
> <https://groups.google.com/d/msgid/modwsgi/7BF16480-8D58-4B6A-AE8E-D8F10668A4AF%40gmail.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 [email protected]
> <mailto:[email protected]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/modwsgi/CALWZDaPGDv9u-635ya%2BQtufzkCYzcOBiS-pJF7E%2B2Mi278ov-w%40mail.gmail.com
>
> <https://groups.google.com/d/msgid/modwsgi/CALWZDaPGDv9u-635ya%2BQtufzkCYzcOBiS-pJF7E%2B2Mi278ov-w%40mail.gmail.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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/modwsgi/5A4A51BC-BB1A-4922-AFEC-811A96DE160D%40gmail.com.