Mar-15-2018, 07:49 PM
Hi @knackwurstbagel!
Thanks for your reply. I took your advice by taking a completely different approach.
I deleted both my remote Django project and local Django project. This time I started a fresh with a new Django project from scratch on my local machine. It runs and behaves beautifully in my development environment. Then I mirrored my new local Django project onto my remote server using rsync.
I changed my apache sites-available ssl configuration file to reflect my new project directory and file names. My new ssl config looks like this:
At this point I’ve ruled out the possibility that the issue has something to do with the Python version 2.7-based libapache2-mod-wsgi because I purged my system of that library. All that exists now is libapache2-mod-wsgi-py3.
My settings.py includes declaration of ALLOWED_HOSTS as [‘daniel496.agency’,’www.daniel496.agency’,]
Here is my site:
https://daniel496.agency/
Still showing:
The last 6 lines of my apache error log are as follows:
So the issue has to do with line 12 of my wsgi.py configuration. Here is wsgi.py and pay particular attention to line 12:
I have consulted this guide to help with deploying Django.
Thanks for your attention.
Thanks for your reply. I took your advice by taking a completely different approach.
I deleted both my remote Django project and local Django project. This time I started a fresh with a new Django project from scratch on my local machine. It runs and behaves beautifully in my development environment. Then I mirrored my new local Django project onto my remote server using rsync.
I changed my apache sites-available ssl configuration file to reflect my new project directory and file names. My new ssl config looks like this:
Quote:<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin <email>
ServerName daniel496.agency
ServerAlias www.daniel496.agency
# DocumentRoot /var/www/html/daniel496.agency/public_html
# ErrorLog ${APACHE_LOG_DIR}/error.log
ErrorLog ${APACHE_LOG_DIR}/daniel496/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# Django project
Alias /static /home/<user>/TheGreatWork/static
<Directory /home/<user>/TheGreatWork/static>
Require all granted
</Directory>
<Directory /home/<user>/TheGreatWork/TheGreatWork>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess TheGreatWork python-home=/home/<user>/TheGreatWork/venv
WSGIProcessGroup TheGreatWork
WSGIScriptAlias / /home/<user>/TheGreatWork/TheGreatWork/wsgi.py
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/daniel496.agency/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/daniel496.agency/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/daniel496.agency/chain.pem
</VirtualHost>
</IfModule>
At this point I’ve ruled out the possibility that the issue has something to do with the Python version 2.7-based libapache2-mod-wsgi because I purged my system of that library. All that exists now is libapache2-mod-wsgi-py3.
My settings.py includes declaration of ALLOWED_HOSTS as [‘daniel496.agency’,’www.daniel496.agency’,]
Here is my site:
https://daniel496.agency/
Still showing:
Quote:Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at [email protected] to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
The last 6 lines of my apache error log are as follows:
Quote:[Thu Mar 15 14:54:23.203156 2018] [:error] [pid 17841] [remote 50.101.151.249:20263] mod_wsgi (pid=17841): Target WSGI script '/home/<user>/TheGreatWork/TheGreatWork/wsgi.py' cannot be loaded as Python module.
[Thu Mar 15 14:54:23.203261 2018] [:error] [pid 17841] [remote 50.101.151.249:20263] mod_wsgi (pid=17841): Exception occurred processing WSGI script '/home/<user>/TheGreatWork/TheGreatWork/wsgi.py'.
[Thu Mar 15 14:54:23.203349 2018] [:error] [pid 17841] [remote 50.101.151.249:20263] Traceback (most recent call last):
[Thu Mar 15 14:54:23.203472 2018] [:error] [pid 17841] [remote 50.101.151.249:20263] File "/home/<user>/TheGreatWork/TheGreatWork/wsgi.py", line 12, in <module>
[Thu Mar 15 14:54:23.203492 2018] [:error] [pid 17841] [remote 50.101.151.249:20263] from django.core.wsgi import get_wsgi_application
[Thu Mar 15 14:54:23.203551 2018] [:error] [pid 17841] [remote 50.101.151.249:20263] ImportError: No module named 'django'
So the issue has to do with line 12 of my wsgi.py configuration. Here is wsgi.py and pay particular attention to line 12:
""" WSGI config for TheGreatWork 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/1.11/howto/deployment/wsgi/ """ import os import sys from django.core.wsgi import get_wsgi_application sys.path.append('/home/<user>/TheGreatWork/TheGreatWork') os.environ.setdefault("DJANGO_SETTINGS_MODULE", "TheGreatWork.settings") application = get_wsgi_application()I’m not sure how line 12 could be improved because I only really partially understand what is going on here. All I understand is that line 22 is referring to this file
/usr/local/lib/python3.4/dist-packages/django/core/wsgi.py
on my system and then from this file, calling the get_wsgi_application
function. Here are the complete contents of this small wsgi.py file:import django from django.core.handlers.wsgi import WSGIHandler def get_wsgi_application(): """ The public interface to Django's WSGI support. Return a WSGI callable. Avoids making django.core.handlers.WSGIHandler a public API, in case the internal WSGI implementation changes or moves in the future. """ django.setup(set_prefix=False) return WSGIHandler()I’m lost. The Apache web server error log is pointing to this function inside the wsgi module. What is the problem here? If the Apache error log is referring to wsgi.py as it appears on my root system instead of where it should be, inside my
venv
, then could the problem be the configuration of my daniel496.agency-le-ssl.conf? I have it listed above and it is not clear to me what the issue is.I have consulted this guide to help with deploying Django.
Thanks for your attention.