not found error on apache + mod_wsgi

692 views
Skip to first unread message

Shane Cleveland

unread,
May 3, 2012, 5:34:24 PM5/3/12
to we...@googlegroups.com
I am receiving a "not found" message in my browser when attempting to access my site as a virtualhost on apache with mod_wsgi. No errors are printed.

Here is my VirtualHost code in httpd-vhosts.conf:

<VirtualHost foo.com:80>
    ServerName foo.com
       ServerAlias foo.com
       DocumentRoot /srv/www/foo.com/public_html/
       ErrorLog /srv/www/foo.com/logs/error.log
       CustomLog /srv/www/foo.com/logs/access.log combined

    WSGIScriptAlias / /srv/www/foo.com/application
    Alias /static /srv/www/foo.com/public_html

    <Directory /srv/www/foo.com/application>
      SetHandler wsgi-script
      Options ExecCGI FollowSymLinks
      # Options +FollowSymLinks
    </Directory>

    AddType text/html .py

    <Location />
      RewriteEngine on
      RewriteBase /
      RewriteCond %{REQUEST_URI} !^/static
      RewriteCond %{REQUEST_URI} !^(/.*)+code.py/
      RewriteRule ^(.*)$ code.py/$1 [PT]
    </Location>
</VirtualHost>

Here is my directory structure:

    application
        code.py
        model.py
logs
public_html
    css
    js
templates
    index.html
    layout.html
    etc ...

Here is my code.py:

#!/usr/bin/env python

# import the web.py module
import sys, os
abspath = os.path.dirname(__file__)
sys.path.append(abspath)
os.chdir(abspath)
import web
import model

# look for templates
render = web.template.render('/srv/www/foo.com/templates/', base='layout')

# url structure
urls = (
'/', 'Index',
'/page', 'Page'
)
app = web.application(urls, globals())

class Index:

def GET(self):
""" Show Index Page """
return render.index()
class Page:

def GET(self):
""" Show Page """
return render.page()

# create application and tell it to start
if __name__ == "__main__":
app.run()
app = web.application(urls, globals(), autoreload=False)
application = app.wsgifunc()


I am able to get the homepage to show up if I go to http://foo.com if I change urls in code.py to:

# url structure
urls = (
'.*', 'Index',
'/page', 'Page'
)

But the index page also shows if I go to http://foo.com/page

Do I need to change urls in code.py some other way?

Thank you for any suggestions!


Shane Cleveland

unread,
May 30, 2012, 12:08:30 PM5/30/12
to we...@googlegroups.com
This post on Stackoverflow helped me solve my problem: http://stackoverflow.com/questions/3613594/web-py-url-mapping-not-accepting
Reply all
Reply to author
Forward
0 new messages