Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am using PHP with apache2 and MySQL on a rackspace server, it is unmanaged cluoud hosting. I am hosting multiple sites using virtual host.

Now i want to use Django on it. A site needs django so I have installed django and mod_wsgi using apt-get install . Then I wrote following lines in my httpd.conf

WSGIScriptAlias / /var/www/djangosite/pyproject/mysite/mysite/wsgi.py
WSGIPythonPath /var/www/djangosite/pyproject/mysite/

<Directory /var/www/djangosite/pyproject/mysite/mysite/>
  <Files wsgi.py>
  Order deny,allow
  Allow from all
  </Files>
</Directory>

But then only django worked on all sites, and only that specific project appear on all sites. so what I need to if I only want it to work for specific site? so that other sites can work as they work previously working with PHP. Do I need to set server name e.t.c. some where?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

See the AddHandler/RewriteRule described in:

That approach will give precedence to static files and/or PHP files under DocumentRoot and only if a match isn't found that way will it fallback to the Django application.

Alternatively, mount your Django application at a sub URL and not at the root of the web site.

WSGIScriptAlias /suburl /var/www/djangosite/pyproject/mysite/mysite/wsgi.py

BTW, your configuration above looks wrong anyway. That could only work if the URL you are using is prefixed by '/wsgi.py'. Did you cut and paste wrong and actually mean:

WSGIScriptAlias / /var/www/djangosite/pyproject/mysite/mysite/wsgi.py

IOW, the last argument should have referenced the wsgi.py file and not the directory.

share|improve this answer
    
Thanks Graham, last issue you mentioned is while copy paste here and I have fixed that by updating my question, other thing is that I don't want to map to suburl. Also every URL fallback to shouldn't also go to wsgi, there can be 404 in PHP sites. I want a way to map by sitename. like if it is specificsite.com/ then use wsgi is there way to tell apache this thing? –  Hafiz Dec 23 '12 at 22:32
    
That is what virtual hosts in Apache are for. See the VirtualHost directive in Apache documentation. –  Graham Dumpleton Dec 24 '12 at 1:24
    
I have already made virtual host for its site but I can specify these lines in : WSGIScriptAlias / /var/www/djangosite/pyproject/mysite/mysite/wsgi.py WSGIPythonPath /var/www/djangosite/pyproject/mysite/ in virtual host file that is in sites-available of apache2 in ubuntu –  Hafiz Dec 24 '12 at 9:55
    
Don't understand the comment. If you are asking whether those directives can be inside of VirtualHost, the answer is yes to WSGIScriptAlias and no to WSGIPythonPath. The Python module path however can be set in the WSGI script file, or better still use daemon mode and set it for the daemon process group. blog.dscpl.com.au/2012/10/… –  Graham Dumpleton Dec 24 '12 at 10:06
    
Thanks Graham, I cut alias from httpd.conf to virtual host file under sites-available and it is working now –  Hafiz Dec 24 '12 at 14:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.