I used the Bitnami Djangostack AMI to set up a Django environment with apache2 and mod_wsgi on a free instance provided by Amazon's EC2. The django app is installed at /opt/bitnami/apps/django/django_projects/mysite, alongside the default Project application that comes with the stack. The app runs on my local computer on the development server without issue. When I transferred the app to the server, I ran the collectstatic script to copy all of the static files to mysite/static, and configured the server to serve STATIC_ROOT at STATIC_URL (settings and configuration details are reported below). As best I can make out, I've configured everything in accordance with the
Django documentation and
modwsgi documentation.
When I point my browser to the server's public address, I see the bitnami startup page, but when I point to the subdirectory mapped to the application, the browser just hangs. It acts as if it's loading a website, spins the little wheel to tell you it's loading a website, and says 'Waiting for xx.xxx.xxx.xxx..." But nothing ever happens. There are no errors reported in /opt/bitnami/apache2/logs/error_log. But If I point instead to a random subdirectory that doesn't exist, I get a 404 page. If I point to the static subdirectory, I get a 403 Forbidden page. If I purposefully add a bug to any of the python code (in e.g. mysite/mysite/urls.py or mysite/myapp/views.py), I get a 500 Internal Server Error and a message in the error_log with the expected python stack trace.
If anyone has any suggestions, I would obviously be very grateful. I'm pretty new to this.
Here are the relevant parts of my configuration files.
/opt/bitnami/apache2/conf/httpd.conf
ServerRoot "/opt/bitnami/apache2"
Listen 80
<IfModule unixd_module>
User daemon
Group daemon
</IfModule>
ServerName localhost:80
DocumentRoot "/opt/bitnami/apache2/htdocs"
<Directory "/opt/bitnami/apache2/htdocs">
Options Indexes FollowSymLinks
AllowOverride None
</Directory>
LoadModule wsgi_module modules/mod_wsgi.so
WSGIPythonHome /opt/bitnami/python
Include "/opt/bitnami/apps/django/conf/mysite.conf"
/opt/bitnami/apps/django/conf/mysite.conf
Alias /static "opt/bitnami/apps/django/django_projects/mysite/static"
<Directory 'opt/bitnami/apps/django/django_projects/mysite/static'>
Order deny,allow
Allow from all
</Directory>
<Directory 'opt/bitnami/apps/django/lib/python2.7/site-packages/django/contrib/'>
<IfVersion < 2.3 >
Order allow,deny
Allow from all
</IfVersion>
<IfVersion >= 2.3>
Require all granted
</IfVersion>
</Directory>
WSGIScriptAlias /mysite "opt/bitnami/apps/django/scripts/mysite.wsgi"
WSGIPythonPath 'opt/bitnami/apps/django/django_projects/mysite/'
<Directory 'opt/bitnami/apps/django/scripts'>
<IfVersion < 2.3 >
Order allow,deny
Allow from all
</IfVersion>
<IfVersion >= 2.3>
Require all granted
</IfVersion>
</Directory>
/opt/bitnami/apps/django/scripts/mysite.wsgi
import os, sys
sys.path.append('/opt/bitnami/apps/django/lib/python2.7/site-packages/')
sys.path.append('/opt/bitnami/apps/django/django_projects')
sys.path.append('/opt/bitnami/apps/django/django_projects/mysite')
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
/opt/bitnami/apps/django/django_projects/mysite/mysite/settings.py
STATIC_ROOT = '/home/bitnami/apps/django/django_projects/mysite/static/'
STATIC_URL = '/static/'