我在Apache上部署了我的Django项目但是当我导航到管理页面时,它似乎没有与Django附带的测试服务器相同的格式。我对配置和软链接进行了大量修改,但到目前为止还没有成功。我希望在Django和Apache中比我更有经验的人可以发现我的问题并诊断出问题。下面是我在安装Django时所采取的步骤以及配置文件的内容。
安装过程
svn co http://code.djangoproject.com/svn/django/trunk/ /usr/share/django
chown -R www-data:www-data /usr/share/django
ln -s /usr/share/django/django /usr/lib/python2.6/dist-packages/django
ln -s /usr/share/django/django/bin/django-admin.py /usr/local/bin/django-admin.py
mkdir /var/www/mydjango/django_projects
mkdir /var/www/mydjango/django_templates
mkdir /var/www/mydjango/media
ln -s /usr/share/django/django/contrib/admin/media /var/www/mydjango/admin_media
django-admin.py startproject /var/www/mydjango/django_projects/mydjango
/var/www/mydjango/django_projects/mydjango/manage.py collectstatic --noinput
(I've added the static files generated to
/usr/share/django/django/contrib/admin/media since it was empty)
settings.py
MEDIA_ROOT = '/var/www/mydjango/media/admin/'
(I've also tried '/var/www/mydjango/media/')
MEDIA_URL = 'http://mydjango.mydomain.com/media/admin/'
STATIC_ROOT = ''
STATIC_URL = '/static/'
的http.conf
Alias /admin_media/ /var/www/mydjango/admin_media/
Alias /media/ /var/www/mydjango/media/
<Directory "/admin_media/">
Order deny,allow
Allow from all
</Directory>
<Directory "/media/">
Order deny,allow
Allow from all
</Directory>
WSGIScriptAlias / /var/www/apache/django.wsgi
<Directory /var/www/apache/>
Order deny,allow
Allow from all
</Directory>
django.wsgi
import os
import sys
path = '/var/www/mydjango/django_projects/mydjango'
if path not in sys.path:
sys.path.append(path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'mydjango.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()