Re: How can Django/WSGI and PHP share / on Apache?

Posted by Bogdan on Server Fault See other posts from Server Fault or by Bogdan
Published on 2011-01-29T23:37:50Z Indexed on 2011/01/31 7:27 UTC
Read the original article Hit count: 623

Filed under:
|
|
|
|

in response to: How can Django/WSGI and PHP share / on Apache?

Hello,

could you please post the complete config file from /sites-available

I am having a problem seems like rewrite engine redirects all requests to django, so static and php files are not served and instead i see the django 404 page. If I get rid of rewrite rule then static files and php works.

here is my apache config file from /sites-available

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /home/www/django
    <Directory />
            Options +FollowSymLinks ExecCGI Indexes
            AllowOverride None
            DirectoryIndex index.php
            AddHandler wsgi-script .wsgi


    </Directory>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ /mysite.wsgi/$1 [QSA,PT,L]

~

and my .wsgi file:

import site

site.addsitedir('/home/user/.virtualenvs/url.com/lib/python2.6/site-packages')

import os, sys

path = '/home/www/django' if path not in sys.path: sys.path.append(path)

os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'

sys.path.append(path + '/mysite') import django.core.handlers.wsgi

_application = django.core.handlers.wsgi.WSGIHandler()

import posixpath def application(environ, start_response):

# Wrapper to set SCRIPT_NAME to actual mount point.
environ['SCRIPT_NAME'] = posixpath.dirname(environ['SCRIPT_NAME'])
if environ['SCRIPT_NAME'] == '/':
    environ['SCRIPT_NAME'] = ''
return _application(environ, start_response)

the document root directory on disk (/home/www/django) contains php files, images, and the mysite.wsgi file.. thanks for your help

© Server Fault or respective owner

Related posts about apache

Related posts about php