In my /etc/apache2/sites-enabled, i have a file site2.com.conf, which defines a virtual host as follows :
<VirtualHost *:80>
ServerAdmin hostmaster@wharfage
ServerName site2.com
ServerAlias www.site2.com site2.com
DirectoryIndex index.html index.htm index.php
DocumentRoot /var/www
LogLevel debug
ErrorLog /var/log/apache2/site2_error.log
CustomLog /var/log/apache2/site2_access.log combined
ServerSignature Off
<Location />
Options -Indexes
</Location>
Alias /favicon.ico /srv/site2/static/favicon.ico
Alias /static /srv/site2/static
# Alias /media /usr/local/lib/python2.5/site-packages/django/contrib/admin/media
Alias /admin/media /var/lib/python-support/python2.5/django/contrib/admin/media
WSGIScriptAlias / /srv/site2/wsgi/django.wsgi
WSGIDaemonProcess site2 user=samj group=samj processes=1 threads=10
WSGIProcessGroup site2
</VirtualHost>
I do the following to enable the site :
1) In /etc/apache2/sites-enabled, i run the command a2ensite site2.com.conf
2) I then get a message site successfully enabled, and then i run the command /etc/init.d/apache2 reload.
But, if i navigate to www.site2.com, i get 404 not found. I do have an index.html in /var/www (permissions:777 and ownership www-data:www-data), and i have also verified that a symlink was created for site2.com.conf in /etc/apache2/sites-enabled.
Any way to fix this ?
Thank you.
Best Answer
Your WSGIScriptAlias directive is saying to send everything except for explicit Alias matched static files, through to Django. Thus, if you are trying to access index.html explicitly it will not use the static one and if Django doesn't know what to do with it, it will return a 404. What is the actual URL you are using? For that URL, do you have matching configuration in Django urls.py for it so Django knows what to do?
Alternatively, issue may be because you don't actually have a /srv/site2/wsgi/django.wsgi file, or because you have not set up an Allow directive for /srv/site2/wsgi like Django/mod_wsgi documentation says you should although lack of that would normally result in 403.
Suggest you comment out WSGIScriptAlias and see what happens first. You would then need to properly explain how you want things to work with actual examples. Reading Django integration guide on mod_wsgi site may also be a good idea.