Symfony和WordPress的nginx配置并排运行

时间:2014-11-05 23:43:48

标签: wordpress symfony nginx

我在/ var / www / mysite / symfony有一个Symfony网站,在/ var / www / mysite / wordpress有一个WordPress博客。如何将mysite.com/blog指向WordPress和Symfony的所有其他请求?这是我到目前为止所尝试的内容:

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;
}

使用此配置,我找不到“找不到文件”。我访问mysite.com/blog时出错。我的nginx日志文件显示FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream。我知道我的php-fpm设置不是问题,因为Symfony在我的网站root上运行良好。

我哪里错了?

1 个答案:

答案 0 :(得分:0)

我找到了在子文件夹中安装wordpress的具体规则:

# 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;
}

此处的原帖:Web Rules: Nginx Rewrites, Redirects and other Cloud Configs | MODX Cloud