NGINX config for using Django + Wordpress

Posted on : 17th Apr 2019

NGINX sample configuration file to integrate a Wordpress blog with your Django project

server {
    server_name ip_addr_or_domain;

    location / {
        include proxy_params;
        proxy_pass http://unix:/home/sith/project/project.sock;
    }

    location ~ /blog/.*\.php$ {
		root /var/www/html;
		index index.php index.html index.htm;
		set $php_root /var/www/html/blog;

		include snippets/fastcgi-php.conf;
		fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }


    location /blog {
		root /var/www/html;
		index index.php index.html index.html;
		set $php_root /var/www/html/blog;

		try_files $uri $uri/ /blog/index.php;
    }
}


With the above configuration for you NGINX server you can use Django project as your primary backend framework, while using Wordpress for url/route /blog/

First location block is for Django, second one for every url starting with /blog/ and ending in *.php extension. The third location block is for static files for your wordpress application

© 2021, All Rights Reserved · Vipin Joshi