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
withODBC 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).