2

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.

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?

1 Answer 1

3

"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
Sign up to request clarification or add additional context in comments.

2 Comments

exactly what I needed and its working . Please edit your answer and add few lines that It need only one conf file and I need to add above lines in wordpress conf file. Anyway Thanks a lot
one problem , Now the Url of django project are not working like I try to open admin -> www.wptesting.com/django/admin , It doesnot work but url becomes wptesting.comhttp%3a//wptesting.com/django/admin . Any idea why its happening

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.