I’m having some issues deploying Django.


Here is my site: https://daniel496.agency/ 


I’m running a Digital Ocean Droplet with Ubuntu 14.04 and Python v3.4 with 
Django 2.0.2 installed.


In this post first I share what errors I am encountering, then what I think 
is the issue is and then what I’ve tried to resolve the issue.  At the end 
of this post are my configuration files like ssl.conf and wsgi.py.


Before I begin, I think the issue might involve the naming of my project 
folders. My project folder on my local machine is named: 
`first_project_attempt`.  But on my remote server, the project folder is 
named, `cel2fah`. I copied the contents locally to my remote host and now 
trying to iron out the issues.


Here I go.  If you access my site linked to above, right now it is showing:


Internal Server Error
> The server encountered an internal error or misconfiguration and was 
> unable to complete your request.
> Please contact the server administrator at <user>@gmail.com 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.
> Apache/2.4.7 (Ubuntu) Server at daniel496.agency Port 443


Here are the last ~50 lines of my apache error log file: 
https://pastebin.com/UPsTmf28 


I’m thinking that there could be a potential conflict between 
libapache2-mod-wsgi and libapache2-mod-wsgi-py3.  I encountered a similar 
issue a few weeks ago. There are apparently still traces of 
libapache2-mod-wsgi (for Python 2.7) still flagged as active on my system 
given that $ sudo dpkg -s libapache2-mod-wsgi prints:


Package: libapache2-mod-wsgi
> Status: deinstall ok config-files
> Priority: optional
> Section: httpd
> Installed-Size: 242
> Maintainer: Ubuntu Developers <ubuntu-devel-disc...@lists.ubuntu.com>
> Architecture: amd64
> Source: mod-wsgi
> Version: 3.4-4ubuntu2.1.14.04.2
> Config-Version: 3.4-4ubuntu2.1.14.04.2
> Provides: httpd-wsgi
> Depends: libc6 (>= 2.14), libpython2.7 (>= 2.7), apache2-api-20120211, 
> python (>= 2.7), python (<< 2.8)
> Conffiles:
> /etc/apache2/mods-available/wsgi.load 06d2b4d2c95b28720f324bd650b7cbd6 
> obsolete
> /etc/apache2/mods-available/wsgi.conf c4ca5be35d0820b5d5cc2892097b476b 
> obsolete
> Description: Python WSGI adapter module for Apache
> The mod_wsgi adapter is an Apache module that provides a WSGI (Web Server
> Gateway Interface, a standard interface between web server software and
> web applications written in Python) compliant interface for hosting Python
> based web applications within Apache. The adapter provides significantly
> better performance than using existing WSGI adapters for mod_python or CGI.
> .
> This package provides module for Python 2.X.
> Homepage: http://www.modwsgi.org/
> Original-Maintainer: Debian Python Modules Team 
> <python-modules-t...@lists.alioth.debian.org>


However when I go to remove it, it says it’s not installed:


$ sudo apt remove libapache2-mod-wsgi
> Reading package lists... Done
> Building dependency tree       
> Reading state information... Done
> Package 'libapache2-mod-wsgi' is not installed, so not removed
> 0 upgraded, 0 newly installed, 0 to remove and 44 not upgraded.


More to the point, when invoking this as root:


apache2ctl -t -D DUMP_MODULES


...it lists what modules apache2 has loaded. And libapache2-mod-wsgi (for 
Python version 2) is included.  So I Google ‘how to remove apache modules’ 
which turns up this SO post: 
https://stackoverflow.com/questions/9288865/how-can-i-uninstall-an-apache2-module

So I set out to rename my libapache2-mod-wsgi.so (for Python version 2) 
from my apache2 modules directory inside /usr/lib. I see a symlink 
mod_wsgi.so which refers to mod_wsgi.so-3.4:


<user>@<host>:/usr/lib/apache2/modules$ ls -la mod_wsgi*
> lrwxrwxrwx 1 root root     15 Nov 18 2014 mod_wsgi.so -> mod_wsgi.so-3.4
> -rw-r--r-- 1 root root 174448 Nov 18  2014 mod_wsgi.so-3.4
> <user>@<host>:/usr/lib/apache2/modules$ 


So is my Apache serving the libapache2-mod-wsgi module for python2 or just 
for python3 or what?


What else can you people determine could be the issue here?


Here is my wsgi.py:

> """
> WSGI config for first_project_attempt 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/tranq/cel2fah/cel2fah')
> # NEW:
> os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cel2fah.settings")
> # OLD:
> # os.environ.setdefault("DJANGO_SETTINGS_MODULE", 
> "first_project_attempt.settings")


application = get_wsgi_application()

And my ssl.conf:


<IfModule mod_ssl.c>
>
> <VirtualHost *:443>
>        ServerAdmin <user>@gmail.com
>        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/tranq/cel2fah/static
>        <Directory /home/tranq/cel2fah/static>
>                Require all granted
>        </Directory>
>        <Directory /home/tranq/cel2fah/cel2fah>
>                <Files wsgi.py>
>                    Require all granted
>                </Files>
>        </Directory>
>        WSGIDaemonProcess cel2fah2 python-home=/home/tranq/cel2fah/venv
>        WSGIProcessGroup cel2fah2
>        WSGIScriptAlias / /home/tranq/cel2fah/cel2fah/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>
>
>
Thanks for your attention.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2f641cca-a9ec-46f0-ac82-6c9db5cb8590%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to