I have a Symfony site at /var/www/mysite/symfony and a WordPress blog at /var/www/mysite/wordpress. How can I direct mysite.com/blog to WordPress and all other requests to Symfony? Here’s what I’ve tried so far:
server {
server_name mysite.com;
root /var/www/mysite/symfony/web;
location / {
try_files $uri /app.php$is_args$args;
}
location ~ ^/(app|app_dev|config).php(/|$) {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
}
location ~ ^/blog {
root /var/www/mysite/wordpress;
try_files $uri $uri/ /blog/index.php?$args;
location ~ .php$ {
fastcgi_split_path_info ^(.+.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
}
}
access_log /var/log/nginx/mysite-access.log;
error_log /var/log/nginx/mysite-error.log;
}
With this configuration I get a ‘File not found.’ error when I visit mysite.com/blog. My nginx log file shows FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream
. I know it’s not an issue with my php-fpm set up as Symfony runs fine at my site root.
Where am I going wrong?
I found a specific rule for installing wordpress in a subfolder:
Original post here: Web Rules: Nginx Rewrites, Redirects and other Cloud Configs | MODX Cloud