Django app is hosted on Ubuntu VM with Apache and mod_wsgi not showing

I downloaded my first Django app, but I'm having trouble accessing it. The app is called a survey and is uploaded to Ubunto VM

works Apache

with mod_wsgi

. My VM was published using a proxy pass at http://phaedrus.scss.tcd.ie/bias_experiment

In the file below, the urls.py

overview should be available at http://phaedrus.scss.tcd.ie/bias_experiment/surveythree/ When I access it locally it works forhttp://127.0.0.1:8000/surveythree/

Recently I posted two related questions (1) (2) and got lots of help on related issues. However, the application is still not visible and I don't understand why.

The steps I took

  • Loaded project to / var / www / (project structure below)
  • Installed virtualenv
  • Mod_wsgi installed
  • Any other related packages installed
  • Created a virtualhost file (below)
  • Created an index.wsgi file (below)
  • Restarting apache
  • Ran a2ensite a2ensite bias_experiment

  • Restarting apache

However, when the user visited http://phaedrus.scss.tcd.ie/bias_experiment/surveythree/ they would get an Apache 404 error page and visit http://phaedrus.scss.tcd.ie/bias_experiment/ will show them the file system ,

Then I added a direct link to the wsgi file by adding below /etc/apache2/sites-available/default

WSGIScriptAlias /bias_experiment/ /var/www/bias_experiment/src/bias_experiment/index.wsgi

      

Now when the user visits http://phaedrus.scss.tcd.ie/bias_experiment/ , they can at least see that Django is running. However, when visiting http://phaedrus.scss.tcd.ie/bias_experiment/surveythree/ , the Apache 404 error page still appears.

Anyone can figure out what is wrong with my setup? I have followed several tutorials and have studied this extensively but cannot figure it out.

Below is my setup . Please do not hesitate to ask for any additional details.

thank

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>

      

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()

      

My urls.py file is 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])),   
)

      

Apace error log tail /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$ 

      

My project structure

enter image description here

Thank!

+1


source to share


1 answer


I think the virtual host is not a starter because the server name you are using is the primary name of that server. So we can probably delete this altogether and we need to focus on what's in /sites-available/default

. And I think the only thing wrong is that we don't need the trailing slash in the alias:

WSGIScriptAlias /bias_experiment /var/www/bias_experiment/src/bias_experiment/index.wsgi

      



(I may have misjudged you twice previously, but this time I found a recommendation in the mod_wsgi documentation directly from the author, Graham Dumpleton.)

+1


source







All Articles