How to run django and wordpress on NGINX server using same domain?
Thanks alex for helping me out to solve this problem.
Here is the solution
Django app dir- /home/ubuntu/django
Wordpress dir - /var/www/html/blog
NGINX Conf file
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
server_name example.com;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location ~ /blog/.*\.php$ {
root /var/www/html;
index index.php index.html index.htm;
set $php_root /var/www/html/blog;
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location /blog {
root /var/www/html;
index index.php index.html index.htm;
set $php_root /var/www/html/blog;
try_files $uri $uri/ /blog/index.php;
}
location /static/ {
alias /home/ubuntu/django/your_app_name/static/static_root/;
}
location /media/ {
alias /home/ubuntu/django/your_app_name/media/ ;
}
}
Note- please replace your home and siteurl with http://example.com/blog in wp-location table of wordpress
Now Your Django app running on example.com
Now Your Blog running on example.com/blog