Run Django project inside wordpress (on suburl of wordpress using Apache and mod_wsgi)

I want to run my wordpress site on main url like www.example.com and Django on its suburl like www.example.com/djnago using Apache and mod_wsgi.

I am trying to implement this on my local machine, I have created two separate .conf files inside /etc/apache/sites-available for both wordpress and django.

Read More

Separately, both are working fine e.g.,

at www.example.com -> wordpress is working

at www.abc123.com -> Django is working

But I want to run django at www.example.com/django from inside the wordpress project and its not working. What I have done is as follows :

Hosts file :

my_system_ip     wptesting.com/django
my_system_ip     wptesting.com

files inside /etc/apache/sites-available :

for wordpress :

<VirtualHost *:80>

ServerName wptesting.com
ServerAlias wptesting.com

DocumentRoot /path_to/wordpress

<Directory /path_to/wordpress/>
AllowOverride All
Order allow,deny

allow from all
#            Options Indexes FollowSymLinks
#            Require all granted
</Directory>
</VirtualHost>

for Django :

<VirtualHost *:80>
WSGIScriptAlias / /path_to/wsgi.py$

ServerName wptesting.com/django
ServerAlias wptesting.com/django

<Directory /path_to_project/>
            Options Indexes FollowSymLinks
            Require all granted
</Directory>
</VirtualHost>

Error : www.wptesting.com is working but www.wptesting.com/django is giving 404 not found error and I think it first hits the wordpress project’s url and then try to map the url www.wptesting/django from the urls defined in wordpress project which is why I am getting this 404 Not Found error. It means Django project is not getting hit at www.wptesting.com/django

Please let me know where I am going wrong, do I need to make only one .conf file inside sites-available and if so then what are the changes that I have to make or is there something else that is wrong?

Related posts

Leave a Reply

1 comment

  1. “wptesting.com/django” is not a server name. “wptesting.com” is the server name, and you want to host the site at “/django” so that is the value you put for WSGIScriptAlias.

    ServerName wptesting.com
    WSGIScriptAlias /django /path_to/wsgi.py