I’m relatively new to anything sysadmin/nginx-related, and experimenting with Digital Ocean’s VPS.
I have a Django app which I’ve got running on my domain (on the root) using Gunicorn and Supervisor (to restart the process). I also serve some static files for the Django app. I’d now like to see if I can serve a WordPress PHP site as well, all on the same server.
Below is my nginx configuration. It works for the Django app and its static files, but WordPress is weird: the WordPress admin works fine, but the frontend fails (just renders a blank page). Is there an obvious error?
For what it’s worth, these are the URLs I’d like to be using:
example.com/
â Django appexample.com/assets/*
â static files (for
Django app)example.com/blog
â WordPress app
Here’s the nginx config:
server {
listen 80;
root /usr/share/nginx/www;
index index.php index.html index.htm;
server_name my.ip.goes.here;
location /assets/ {
alias /opt/foo/assets/;
expires max;
access_log off;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
proxy_ignore_headers "Cache-Control" "Expires" "X-Accel-Expires" "Set-Cookie";
}
location /blog/ {
try_files $uri $uri/ /blog/index.php?q=$uri&$args;
}
location ~ .php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location / {
proxy_pass my.ip.goes.here:8001;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
}
}
What am I missing to make the /blog/
subfolder properly serve the WordPress instance? The admin (/blog/wp-admin/index.php
) serves correctly and is fully usable.
My own error. The config was right (it was a giveaway that the admin worked fine and there was nothing in the nginx error log): I’d connected an existing WordPress database to a fresh WP install and the theme I was using didn’t exist.