Nginx configuration for symfony and wordpress working next to each other

I have a symfony site in / var / www / mysite / symfony and a WordPress blog in / var / www / mysite / wordpress. How can I submit mysite.com/blog to WordPress and all other symfony requests? Here is what I have 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;
}

In this configuration, I get "File not found". error visiting mysite.com/blog. In my log file, nginx is displayed FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream. I know that this is not a problem with setting up php-fpm, since Symfony works fine with my site root.

Where am I going wrong?

+4
source share
1 answer

I found a specific rule for installing wordpress in a subfolder:

# Replace all occurrences of [subfolder] with the folder where your WordPress install is located

# The WordPress rewrite
location /[subfolder] {
    try_files $uri $uri/ /[subfolder]/index.php?$args;
}

# The default MODX rewrite</h1>
location / {
    try_files $uri $uri/ @modx-rewrite;
}

: -: Nginx Rewrites, | MODX

0

All Articles