I am trying to deploy my first Django application (on A2 Hosting). Unfortunately, I don't have access to my Apache2 conf file (and/or httpd), I can only modify the .htaccess file than you can see below. After many try, I think it is the Apache server who can't load the wsgi.py, because I add a logs file, create when the wsgi.py file is called and it wasn`t create (I tried manually and the logs file are correctly created).
Right now, all I am trying to do its to print the Django "Wello World", because I thought, if I can't pass through this basic step, how can I deploy my "real" application ... Finally, I am running with Django 1.11.6 and Python 3.5.4 on a virtual env.
.htaccess
DirectoryIndex /home/hairduseres/public_html/myapp/myapp/myapp/wsgi.py
WSGIScriptAlias / /home/user/public_html/myapp/myapp/myapp/wsgi.py
WSGIPythonHome /home/user/virtualenv/myapp/3.5
WSGIPythonPath /home/user/public_html/myapp
<Directory /home/user/public_html/myapp/myapp/myapp/>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
# DO NOT REMOVE. CLOUDLINUX PASSENGER CONFIGURATION BEGIN
PassengerAppRoot "/home/user/public_html/myapp"
PassengerBaseURI "/myapp"
PassengerPython "/home/user/virtualenv/myapp/3.5/bin/python3.5"
# DO NOT REMOVE. CLOUDLINUX PASSENGER CONFIGURATION END
wsgi.py
"""
WSGI config for myapp 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
from django.core.wsgi import get_wsgi_application
print('===== sys.path / PYTHONPATH =====')
for k in sorted(os.environ.keys()):
v = os.environ[k]
print ('%-30s %s' % (k,v[:70]))
print(os.environ['VIRTUAL_ENV'])
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myapp.settings")
logs = open("/home/user/logs", 'a')
logs.write("(wsgi.py) file correctly load \n")
logs.close()
application = get_wsgi_application()
I already have a look on : Django AND .htaccess rewrites/redirects, is this possible? , Configure WSGI with Django on OpenShift , on the Django web site of course and also many other web site, unfortunately they explain how to deploy Django application when the user have access to the Apache conf file ...