Django应用程序托管在Ubuntu VM与Apache和mod_wsgi的没有显示出来 [英] Django application hosted on Ubuntu VM with Apache and mod_wsgi not showing up
问题描述
我已经上传我的第一个Django应用程序,但我有麻烦访问它。该应用程序名为调查并一直与<上传到一个 Ubunto VM
运行的Apache
code>的mod_wsgi 。我的VM已公开使用代理通在 http://phaedrus.scss.tcd.ie/bias_experiment
I have uploaded my first Django Application but I am having trouble accessing it. The application is called survey and has been uploaded onto an Ubunto VM
running Apache
with mod_wsgi
. My VM has been made public using a Proxy pass at http://phaedrus.scss.tcd.ie/bias_experiment
每 urls.py
以下文件,调查应提供的 http://phaedrus.scss.tcd.ie/bias_experiment/surveythree/ 当我访问它在当地它工作在 http://127.0.0.1: 8000 / surveythree /
Per the urls.py
file below, the survey should be available at http://phaedrus.scss.tcd.ie/bias_experiment/surveythree/ When I access it locally it works at http://127.0.0.1:8000/surveythree/
我已经发布了两个相关的<一个问题href=\"http://stackoverflow.com/questions/24209181/what-should-be-the-url-of-my-django-application\">(1)(2)这和最近收到很多的帮助就相关问题。然而,应用程序仍然是不可见的,我不明白为什么。
I have posted two questions related (1)(2) to this lately and have received lots of help on related issues. However the application is still not visible and I do not understand why.
的步骤我把
- 上传项目到/ var / WWW /(项目结构如下)
- 已安装的virtualenv
- 已安装的mod_wsgi
- 安装了其他相关的软件包
- 创建的虚拟主机文件(如下图)
- 创造了index.wsgi文件(如下图)
- 重启动Apache的
- 冉a2ensite
a2ensite bias_experiment
- 重启动Apache的
然而,当用户访问 http://phaedrus.scss.tcd.ie/bias_experiment/ surveythree / 他们会得到一个Apache的404错误页面,参观 HTTP://phaedrus.scss。 tcd.ie/bias_experiment/ 将展示他们的文件系统,
However when the user visited http://phaedrus.scss.tcd.ie/bias_experiment/surveythree/ they would get an Apache 404 error page and visiting http://phaedrus.scss.tcd.ie/bias_experiment/ would show them the file system,
然后我通过添加下面的/ etc / apache2的/网站的可用/默认
WSGIScriptAlias /bias_experiment/ /var/www/bias_experiment/src/bias_experiment/index.wsgi
现在,当用户访问 http://phaedrus.scss.tcd.ie/bias_experiment/他们至少看到Django的运行。但是访问 http://phaedrus.scss.tcd.ie/bias_experiment/surveythree/ 仍然导致Apache的404错误页面。
Now when the user visits http://phaedrus.scss.tcd.ie/bias_experiment/ they at least see Django is running. However visiting http://phaedrus.scss.tcd.ie/bias_experiment/surveythree/ still results in an Apache 404 error page.
有人能看到什么是错我的设置?我按照多个教程和广泛地看着这一点,但不能弄明白。
Can anyone see what is wrong with my setup? I have followed multiple tutorials and extensively looked into this but cannot figure it out.
以下是我的设置请随时要求任何aditional的细节。
The below is my setup Please feel free to request any aditional details.
感谢
我的虚拟主机文件位于的/ etc / apache2的/网站的可用/ bias_experiment
My VirtualHost file located at /etc/apache2/sites-available/bias_experiment
<VirtualHost *:80>
ServerAdmin myemail@gmail.com
ServerName phaedrus.scss.tcd.ie/bias_experiment
ServerAlias phaedrus.scss.tcd.ie
WSGIScriptAlias /bias_experiment/ /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>
我的index.wsgi文件位于 /var/www/bias_experiment/src/bias_experiment/index.wsgi
My index.wsgi file located at /var/www/bias_experiment/src/bias_experiment/index.wsgi
import os
import sys
import site
# This was kept in order to add the src folder
sys.path.append('/var/www/bias_experiment/src')
sys.path.append('/var/www/bias_experiment/src/bias_experiment')
os.environ['DJANGO_SETTINGS_MODULE'] = '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()
我的urls.py文件位于 /var/www/bias_experiment/src/bias_experiment/urls.py
My urls.py file located at /var/www/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])),
)
我的宇瞻错误日志 尾/var/log/apache2/error.log
(bias_experiment)spillab@kdeg-vm-18:/var/www/bias_experiment$ sudo tail /var/log/apache2/error.log
[Sun Jun 15 17:37:26 2014] [error] [client 134.226.38.233] Target WSGI script not found or unable to stat: /var/www/bias_experiment/src/bias_experiment/index.wsgisurveythree
[Sun Jun 15 17:37:50 2014] [error] [client 134.226.38.233] Target WSGI script not found or unable to stat: /var/www/bias_experiment/src/bias_experiment/index.wsgisurveythree
[Sun Jun 15 18:38:11 2014] [error] [client 134.226.38.233] Target WSGI script not found or unable to stat: /var/www/bias_experiment/src/bias_experiment/index.wsgisurveythree
[Sun Jun 15 18:39:53 2014] [error] [client 134.226.38.233] Target WSGI script not found or unable to stat: /var/www/bias_experiment/src/bias_experiment/index.wsgisurveythree
[Sun Jun 15 18:40:00 2014] [error] [client 134.226.38.233] Target WSGI script not found or unable to stat: /var/www/bias_experiment/src/bias_experiment/index.wsgisurveythree
[Sun Jun 15 18:40:01 2014] [error] [client 134.226.38.233] Target WSGI script not found or unable to stat: /var/www/bias_experiment/src/bias_experiment/index.wsgisurveythree
(bias_experiment)spillab@kdeg-vm-18:/var/www/bias_experiment$
我的项目结构
谢谢!
推荐答案
我觉得虚拟主机是一个非首发,因为你正在使用的服务器名称是的主要的该服务器的名称。因此,我们或许可以删除完全,我们需要集中精力在什么 /站点可用/默认
。我认为,唯一有错的是我们不需要的别名斜线:
I think the virtual host is a non-starter, because the server name you are using is the main name of that server. So we can probably delete that altogether, and we need to concentrate on what's in /sites-available/default
. And I think the only thing wrong there is that we don't need a trailing slash in the alias:
WSGIScriptAlias /bias_experiment /var/www/bias_experiment/src/bias_experiment/index.wsgi
(我可能有previously带领你错上加错上,但是这一次,我发现从作者,格雷厄姆邓普尔顿直接的mod_wsgi文档中的建议。)
(I might have previously steered you doubly wrong on that, but this time I found the recommendation in the mod_wsgi documentation directly from the author, Graham Dumpleton.)
这篇关于Django应用程序托管在Ubuntu VM与Apache和mod_wsgi的没有显示出来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!