我想部署一个Django应用程序的第一次使用mod_wsgi
与Apache
在Ubuntu 12.04
虚拟机。我一直在以下几个教程,特别是Ayman Farhat blog,这excellent YouTube video当然官方的Django文档Django应用程序不可见
在此之前的earlier question I posted here不知道为什么,当我上传到/ var/WWW /(脸红了我的Django的调查并没有简单地工作! )我已经根据答案查看了mod_wsgi
。
我不知道我失踪了什么阶段。该项目可以通过python manage.py runserver
在服务器上启动,没有任何错误。我也跑了python manage.py collectstatic
没有错误。
然后,我
sudo service apache2 restart
但是重新启动Apache,当我去的URL http://phaedrus.scss.tcd.ie/bias_experiment/surveythree/,我希望看到调查无所不有。我只看到标准的404错误。
我真的不确定接下来要做什么或者为什么这不起作用。
下面是我的设置和我迄今为止所尝试的。
注意:我有一个在Pydev中创建的Bias_Experiment Django项目。它有三个应用程序包含在src
文件夹中。
- 调查(我的工作的项目)
- 民意调查(一个教程中,我被下)
- bias_experiment(我设置的根应用程序文件等)
我的项目结构
我的虚拟主机位于/etc/apache2/sites-available/bias_experiment
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName kdeg-vm-18.scss.tcd.ie
ServerAlias http://collegeserver.ie/bias_experiment
WSGIScriptAlias/var/www/bias_experiment/src/bias_experiment/index.wsgi
Alias /static/ /var/www/bias_experiment/src/bias_experiment/static/
<Location "/static/">
Options -Indexes
</Location >
</VirtualHost >
我WSGI文件位于/var/www/bias_experiment/src/bias_experiment/index.wsgi
import os
import sys
import site
# Add the site-packages of the chosen virtualenv to work with
site.addsitedir('~/var/www/bias_experiment/lib/python2.7/site-packages')
# Add the app's directory to the PYTHONPATH
sys.path.append('/var/www/bias_experiment')
sys.path.append('/var/www/bias_experiment/src/bias_experiment')
os.environ['DJANGO_SETTINGS_MODULE'] = 'bias_experiment/src/bias_experiment.settings'
# Activate your virtual env
activate_env=os.path.expanduser("~/var/www/bias_experiment/bin/activate_this.py")
execfile(activate_env, dict(__file__=activate_env))
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
我的URL模式从bias_experiment/src/bias_experiment/urls.py
urlpatterns = patterns('',
url(r'^polls/', include('polls.urls', namespace="polls")),
url(r'^admin/', include(admin.site.urls)),
url(r'^surveythree/$', SurveyWizard.as_view([SurveyForm1, SurveyForm2, SurveyForm3, SurveyForm4, SurveyForm5])),
)
感谢您的帮助;-)我不知道我应该访问的地址应该匹配服务器名称或别名,我会尝试一些变化后,我做了其他更改。 – Deepend
我已根据您的指示更新了ServerAlias和WSGIScriptAlias。我的代码在'/ var/www /'not'〜/ var/www /我也改变了这个。我也做了其他改变。 – Deepend
由于这些变化,我仍然没有看到预期的结果。我正在通过http://phaedrus.scss.tcd.ie/bias_experiment公开的私有虚拟机托管。我认为这种困惑是问题的根源。我认为现在最好能够发布另一个问题,重点关注这些问题已经解决了吗? – Deepend