1

I want to run WordPress at mysite.com/, because it's easier to edit sales copy and such. I want to run my Django site within mysite.com/members/

httpd.conf:

<VirtualHost *:80>
ServerName mysite.com
ServerAlias www.mysite.com
DocumentRoot /var/www/mysite.com
WSGIDaemonProcess mysite python-path=/var/www/mysite.com/mysite:/var/www/mysite.com/
WSGIProcessGroup mysite
WSGIScriptAlias / /var/www/mysite.com/mysite/mysite/wsgi.py
</VirtualHost>

What exactly do I need to do so that Django runs within the /members/ directory on my domain/website?

User
  • 23,729
  • 38
  • 124
  • 207

2 Answers2

5

Use:

WSGIScriptAlias /members /var/www/mysite.com/mysite/mysite/wsgi.py

Do be aware that by doing that, since you have made the mistake of setting DocumentRoot to be a parent directory of your source code, people will be able to download the source code, including sensitive information in the settings module.

So, do not set DocumentRoot to be what you have. Have it refer to an en empty directory, of the default htdocs directory for the whole server.

Graham Dumpleton
  • 57,726
  • 6
  • 119
  • 134
  • Thanks, And I have my site at /Wordpress/ but it should appear at / – User Jun 03 '15 at 23:27
  • 1
    Normally for a PHP site the PHP files would be located in the directory DocumentRoot is referring to. How have you set up Wordpress configuration? If PHP files are in DocumentRoot then mounting Django application at sub URL should not interfere with Wordpress out of root of site. The WSGIScriptAlias will ensure that only requests to /members got to the Python application. – Graham Dumpleton Jun 03 '15 at 23:33
  • I have somedir/Wordpress and somedir/django. Can I put document root at somedir/Wordpress then? – User Jun 03 '15 at 23:35
  • 1
    With the way that PHP is generally setup as an Apache filter on .php file extensions, then yes, I believe that setting DocumentRoot to that directory may work. You may need to setup access controls for that directory and specify DirectoryIndex to map to top page for Wordpress. Am not sure what setup requirements for Wordpress are. – Graham Dumpleton Jun 04 '15 at 00:14
0

To follow up on the previous answer and comments, here's an example of how I might do this if I had to:

<VirtualHost *:80>
    # WordPress
    ServerName mysite.com
    ServerAlias www.mysite.com
    DocumentRoot /var/www/mysite.com

    # Django
    WSGIDaemonProcess mysite python-path=/var/django/django_project/virtualenv/django_project
    WSGIProcessGroup mysite
    WSGIScriptAlias /members /var/django/django_project/django_project/wsgi.py
    Alias /members/static/ /var/django/django_project/static/
</VirtualHost>

Definitely understand the security concerns raised in comments, however.

FlipperPA
  • 13,607
  • 4
  • 39
  • 71