0
ServerName test.test.nz

    ServerAdmin webmaster@localhost
    DocumentRoot /home/aut/sampleapp


    WSGIScriptAlias /home/aut/sampleapp /home/aut/sampleapp/sampleapp/wsgi.py
    WSGIPythonPath /home/aut/sampleapp:/home/aut/sampleapp/env/lib/python2.7/site-packages

    <Directory /home/aut/sampleapp>
            AllowOverride None
            Options +FollowSymLinks
            Order allow,deny
            Allow from all
            Require all granted
    </Directory>

    <Directory /home/aut/sampleapp/sampleapp>
    <Files wsgi.py>
            Require all granted
    </Files>
    </Directory>

The above is the configuration for virtual host port 80. After restarting Apache, I got no errors, but when I go to test.test.nz, I get:

The requested URL / was not found on this server.

"/home/aut/sampleapp/" is where manage.py is, within that directory, there is another folder called "sampleapp" which contains the urls.py, wsgi.py etc..

The urls.py has been edited to set the app as the index page:

from django.conf.urls import url
from django.contrib import admin
from django.contrib.sitemaps import views

urlpatterns = [
    url(r'^$', views.index, name='index'),
    url(r'^admin/', admin.site.urls),
]

What seems to be the problem?

Any help or direction would be appreciated.

Thanks in advance,

3
  • 1
    Don't set DocumentRoot to be a directory containing your source code, it weakens the security of your setup as any stuff up and people may be able to download your source code. Make sure you use daemon mode of mod_wsgi. Setting up of Python virtual environment better done other ways. See blog.dscpl.com.au/2012/10/… blog.dscpl.com.au/2009/11/save-on-memory-with-modwsgi-30.html blog.dscpl.com.au/2014/09/… Commented Aug 7, 2016 at 10:28
  • @GrahamDumpleton Hi. Thanks for the advise. I have used daemon mode as you suggested, but what do you suggest I should change the DocumentRoot to? "/home/aut"? Commented Aug 8, 2016 at 6:23
  • Using /home/aut would be even worse. Create an empty directory /home/aut/sampleapp/htdocs and point it at that. If you don't use the main Apache htdocs for anything, just leave it unset and will fall back to using the main Apache one. Commented Aug 8, 2016 at 9:17

1 Answer 1

1

You haven't defined anything for the root path, /. Your wsgiscriptalias is set to "/home/aut/sampleapp" so only applies to paths under that.

I'm not quite sure why you've done this; if you want wsgi to serve your site at the root, as you usually would, you should put / there.

Sign up to request clarification or add additional context in comments.

4 Comments

To get a perspective, where exactly is the site served based on my current configuration? and if I set it as the root path, would it be accessible from "test.test.nz"? Thanks.
It's served from home/aut/sampleapp now.
I tried "test.test.nz/home/aut/sampleapp" but get the same result. I will replace "/home/aut/sampleapp" with "/" and ask administrator to restart Apache and let you know how it goes.
Is there anything else that needs changing other than WSGIScriptAlias?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.