Innovate anywhere, anytime withruncode.io Your cloud-based dev studio.
Amazon Web Services

Django Hosting on Amazon EC2 with Wordpress on Same Domain

2022-07-19

Installing Prerequisites:

sudo apt-get install nginx python-dev python-pip python-virtualenv mysql-server nginx php5-fpm php5-mysql
aws-mp-banner

Folder Structure:

/home/ubuntu/micropyramid
├── blog
│   ├── blog files
├── env
└── micropyramid_django
    └── django files

Nginx Configuration for Wordpress on Subdomain

server {
    listen 80 default_server;
    server_name example.com;

    location @wp {
      rewrite ^/blog(.*) /blog/index.php?q=$1;
    }

    location ^~ /blog {
        root /home/ubuntu/micropyramid;
        index index.php index.html index.htm;
        try_files $uri $uri/ @wp;

location ~ \.php$ {
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $request_filename;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
           }
    }
}

You can follow this link for configuring Django Application on domain.  Now example.com should serve your django application and example.com/blog will serve your Wordpress Blog.