1

I am setting up a Turnkey Django solution and it works perfectly fine if you use the pre-built Django project they provide. But it's a pain to work with and breaks many of the rules and guidelines in the Django documentation and includes so much bloat that it breaks the moment you upgrade or install a new package. So I am trying to setup it up so that I can make my own Django project from the ground up with my own file paths.

All my databases, dependencies, packages and Django files are in working order within a virtualenv but when I go to edit my Apache config file with my custom directories it throws a 404.

Here is what I am using and the versions:

  • PuTTy, SSH into the server (Windows 10 --SSH-> Linux)
  • virtualenv, contains the Django project and several packages
  • Django (2, 1, 6, 'final', 0)
  • Python 3.6.8
  • Turnkey GNU/Linux 9.6
  • sql_server.pyodbc with ODBC Driver 17 for SQL Server for MSSQL

Note: In Turnkey Django the Apache config files is a little different from standard Apache. 000-default.conf does nothing in Turnkey Django.

So when I change django.conf in /root/etc/apache2/sites-available from the defualt:

   serverName localhost

   WSGIScriptAlias / /var/www/turnkey_project/turnkey_project/wsgi.py
   WSGIPythonPath /var/www/turnkey_project
   WSGIDaemonProcess django processes=1 threads=3
   WSGIProcessGroup django

   <VirtualHost *:80>
       UseCanonicalName Off
       ServerAdmin  webmaster@localhost
       DocumentRoot /var/www/turnkey_project/static
   </VirtualHost>

   <VirtualHost *:443>
       SSLEngine on
       ServerAdmin  webmaster@localhost
       DocumentRoot /var/www/turnkey_project/static
   </VirtualHost>

   Alias /static /var/www/turnkey_project/static
   <Location "/static">
       SetHandler None
   </Location>

   Alias /doc /usr/share/doc/python-django-doc/html
   <Location "/doc">
       SetHandler None
   </Location>

To what I assumed would work with my own file paths but does not:

   ServerName localhost

   WSGIScriptAlias / /var/www/sys/main/wsgi.py
   WSGIPythonPath /var/www/sys
   WSGIDaemonProcess django processes=1 threads=3
   WSGIProcessGroup django

   <VirtualHost *:80>
       UseCanonicalName Off
       ServerAdmin  webmaster@localhost
       DocumentRoot /var/www/sys/static
   </VirtualHost>

   <VirtualHost *:443>
       SSLEngine on
       ServerAdmin  webmaster@localhost
       DocumentRoot /var/www/sys/static
   </VirtualHost>

   Alias /static /var/www/sys/static
   <Location "/static">
       SetHandler None
   </Location>

   Alias /doc /var/www/sys/doc/html
   <Location "/doc">
       SetHandler None
   </Location>

So why does it throw a 404 when I navigate to my IP? Am I setting it up wrong or is Turnkey just too restrictive? Everything seems to be in working order but it just does not want to work.

I have an app in my Django project and for those who are familiar with Django and it's URL patterns will know it will automatically change the url from foo.com/bar to foo.com/bar/ (notice the suffixed '/'). When I "navigate" to my app it does apply this change automatically maybe suggesting Django is working properly but maybe my directories in my apache config isn't right or my file layout isn't correct (maybe).

Moms
  • 11
  • 1

1 Answers1

0

Sorry for such a slow response. I'm subscribed to the 'turnkey-linux' tag but for some reason did not get notification re this?! I'm guessing that you've probably moved on by now, but here's my 2c:

First up it's worth being aware of a few things. Under the hood, TurnKey is Debian. It is tweaked a bit and we do provide a few of our own custom packages, but mostly it's Debian. In our Django appliance, we install Django from the Debian repos.

The TurnKey "example" app isn't intended to be anything more than a sandpit to have a play with (and also as a quick smoke test to make sure everything is in place).

TBH, with the info you've provided it's really hard to even guess what the issue might be. You should at least consult your apache log (/var/log/apache2/error.log) and that will most likely make it clear what it can't find (and perhaps even why).

My guess is that you have one of your paths wrong. Or perhaps it's a permissions issue? (I.e. the webserver user doesn't have access to something it needs access to). But I'm only guessing...

Jeremy Davis
  • 406
  • 4
  • 15