wordpress - Symfony 和 WordPress 并行运行的 nginx 配置

标签 wordpress symfony nginx

我有一个 Symfony 站点(位于/var/www/mysite/symfony)和一个 WordPress 博客(位于/var/www/mysite/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 在 stderr 中发送:“主脚本未知”,同时从上游读取响应 header 。我知道这不是我的 php-fpm 设置的问题,因为 Symfony 在我的站点根目录下运行良好。

我哪里出错了?

最佳答案

我发现了在子文件夹中安装 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

关于wordpress - Symfony 和 WordPress 并行运行的 nginx 配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26769292/

相关文章:

php - 全局Wordpress IMG目录功能

php - 如何在 wordpress 中的 fonts.php 之后加载 style.css?

python - Flask + Docker 应用程序 - 当我运行 docker run 时容器死亡

nginx - gke nginx lb 运行状况检查/无法获取处于 "healthy"状态的所有实例

nginx - 用于媒体文件的 Flask send_from_directory

iPhone 和 iPad WordPress 菜单不良行为

php - 使用 get_post_meta 数组作为 meta_query 值

symfony - 有没有办法从 symfony 2.0.x 项目生成 Composer 锁定文件?

php - 当实体重复时跳过实体并刷新

php - 有没有办法在子进程中传递服务/容器?