I setup, django App with Apache2,
1) Virtual host:
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName alpha101.publisy.com
DocumentRoot /var/www/mysite
WSGIScriptAlias / /usr/local/django/mysite/apache/django.wsgi
Alias /static/ /var/www/mysite/media/static/
<Directory /var/www/mysite/media/static>
Order deny,allow
Allow from all
</Directory>
Alias /media/ /var/www/mysite/media/
<Directory /var/www/mysite/media>
Order deny,allow
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
2) wsgi script (located at /usr/local/django/mysite/apache/django.wsgi)
import os, sys
sys.path.append('/usr/local/django')
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
Can anybody suggest what goes wrong?
There seems to be a little problem. Looks like your "site' directory is /var/www/mysite
.
Add this to your python path in django.wsgi.
sys.path.append('/var/www')
sys.path.append('/var/www/mysite')
Infact the error you posted
TemplateSyntaxError: Caught an exception while rendering: No module named destinations
It seems that wsgi can't find the module destinations. Add the directory path to your python path in django.wsgi and it should work.
If you have DEBUG=False
or your ip address is not in the INTERNAL_IPS
any django error will give you Error 500, even a thing like KeyError
. Usually, production server has a diffences in the inviroment, so, even if everything ran ok on localhost, you might find some problems in production.
Two ways to see what is wrong:
INTERNAL_IPS
(get your current ip address) or set DEBUG
to true
Also, remember, that you have to restart the server after making changes.
Good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With