How to run Django and Wordpress using Nginx and Gunicorn at the same domain? -


i have django app running on domain e.g. www.example.com

i want create wordpress landing page, , point landing page home url www.example.com , wordpress admin site www.example.com/admin or www.example.com/wp-admin. other urls should served django.

so, want:

  • www.example.com -> wordpress
  • www.example.com/admin or www.example.com/wp-admin -> wordpress
  • all other urls served django

till now, nginx configuration using django:

upstream django_server {     server unix:/path/to/gunicorn.sock fail_timeout=0; }  server {      listen   80;     server_name www.example.com example.com     client_max_body_size 4g;      access_log /path/to/nginx-access.log;     error_log /path/to/nginx-error.log;      location /static/ {         alias   /path/to/static/;     }      location /media/ {         alias   /path/to/media/;     }      location / {         proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;         proxy_set_header host $http_host;         proxy_redirect off;         if (!-f $request_filename) {             proxy_pass http://django_server;             break;         }     }      error_page 500 502 503 504 /500.html;     location = /500.html {         root /path/to/static/;     } } 

any appreciated.

wordpress uses indeterminate set of urls , important have clear partition between , set of urls available django. best solution place wordpress subdirectory (which surprisingly easy).

for example:

server {     ...     # existing django configuration     ...      location = / {         return $scheme://$host/blog/;     }     location ^~ /blog {         alias /path/to/wordpress;          index index.php;         if (!-e $request_filename) { rewrite ^ /blog/index.php last; }          location ~ /wp-content/uploads/ { expires 30d; }          location ~ \.php$ {             if (!-f $request_filename) { rewrite ^ /blog/index.php last; }              include       fastcgi_params;             fastcgi_param script_filename $request_filename;             ...         }         location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {              if (!-f $request_filename) { rewrite ^ /blog/index.php last; }             expires 30d;          }     } } 

you need set site , home urls. see this document details.

see this document more.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -