virtualhost中应用程序的nginx嵌套子文件夹

virtualhost中应用程序的nginx嵌套子文件夹,nginx,virtualhost,subdirectory,Nginx,Virtualhost,Subdirectory,我正在尝试在服务器上运行2个应用程序 根文档上的第一个应用程序(wordpress) 文件夹/应用程序中的第二个应用程序(symfony4) 问题是我找不到在嵌套文件夹上使用别名的方法。。。 我的配置文件: server { listen 80; server_name ~^(?<folder>[^.]*).magana.dev.hexis.fr; charset utf-8; index index.php index.html index.h

我正在尝试在服务器上运行2个应用程序

  • 根文档上的第一个应用程序(wordpress)
  • 文件夹/应用程序中的第二个应用程序(symfony4)
问题是我找不到在嵌套文件夹上使用别名的方法。。。 我的配置文件:

server {
  listen 80;

    server_name ~^(?<folder>[^.]*).magana.dev.hexis.fr;


    charset utf-8;
    index index.php index.html index.htm;

    root /var/www/projects/dev/magana/$folder/htdocs;
    access_log /var/www/projects/dev/magana/$folder/access.log;
    error_log  /var/www/projects/dev/commons/logs/magana_error.log;

    client_max_body_size 200M;

    location ~* .(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf|js|css)$ {
        access_log        off;
        log_not_found     off;
        expires           30d;
        add_header Pragma "public";
    }

    location / {
        try_files $uri $uri/ /index.php?q=$uri&$args;
    }


    location ~ \.php$ {            
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_param APPLICATION_ENV magana;
        include fastcgi_params;
        fastcgi_read_timeout 600;
        fastcgi_buffers 16 16k; 
        fastcgi_buffer_size 32k;
        fastcgi_param SERVER_NAME $folder.magana.dev.hexis.fr;
   }
location /app {
        alias /var/www/projects/dev/magana/$folder/htdocs/app/public;
        try_files $uri $uri/ @app;

        location ~ \.php$ {
            fastcgi_param SCRIPT_FILENAME $request_filename;
            fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        }
    }

    location @app {
        rewrite /app/(.*)$ /app/public/index.php?/$1 last;
    }
   location ~ /\.ht {
        deny all;
    }
}
服务器{
听80;
服务器名称~^(?[^.]*)。magana.dev.hexis.fr;
字符集utf-8;
index.php index.html index.htm;
root/var/www/projects/dev/magana/$folder/htdocs;
access_log/var/www/projects/dev/magana/$folder/access.log;
error_log/var/www/projects/dev/commons/logs/magana_error.log;
客户最大身体尺寸200M;
(ogg | ogg | ogv | ogg | ogv | ogg | ogg | ogg | ogg | ogg | ogv | ogv | ogv | svg | svg | SVG124政政政协| O夫124夫124夫瓦夫124政政政政协|沃夫夫124夫124夫|沃夫夫夫夫夫124政政政政政政政协1244 1244 124政政政政政协1244 124412441244124;瓦夫|瓦夫124政政政政政政政政政协1244{
访问/注销;
未发现注销日志;
过期30天;
添加标题Pragma“public”;
}
地点/{
try_files$uri$uri//index.php?q=$uri&$args;
}
位置~\.php${
try_files$uri=404;
fastcgi\u split\u path\u info^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
fastcgi_index.php;
fastcgi\参数脚本\文件名$document\根$fastcgi\脚本\名称;
fastcgi_param应用程序_ENV magana;
包括fastcgi_参数;
fastcgi_读取超时600;
fastcgi_缓冲器16 16k;
fastcgi_缓冲区大小32k;
fastcgi_参数服务器名称$folder.magana.dev.hexis.fr;
}
位置/应用程序{
别名/var/www/projects/dev/magana/$folder/htdocs/app/public;
尝试_files$uri$uri/@app;
位置~\.php${
fastcgi_参数脚本_文件名$request_文件名;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
}
位置@app{
重写/app/(*)$/app/public/index.php?/$1 last;
}
位置~/\.ht{
否认一切;
}
}
我错过了什么?
感谢您的帮助

使用此代码,我可以访问该应用程序,但仍然找不到声明e=kernelrootdirectory的方法

server {
  listen 80;

    server_name ~^(?<folder>[^.]*).magana.dev.example.fr;


    charset utf-8;
    index index.php index.html index.htm;

    set $symfonyRoot /var/www/projects/dev/magana/$folder/htdocs/app/public;
        set $symfonyScript index.php;

    root /var/www/projects/dev/magana/$folder/htdocs;
    access_log /var/www/projects/dev/magana/$folder/access.log;
    error_log  /var/www/projects/dev/commons/logs/magana_error.log;

    client_max_body_size 200M;

    location ~* .(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp$
        access_log        off;
        log_not_found     off;
        expires           30d;
        add_header Pragma "public";
    }
    location /app {
                root $symfonyRoot;
                rewrite ^/app/(.*)$ /$1 break;
                try_files $uri @symfonyFront;
        }
    location @symfonyFront {
                fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
                include /etc/nginx/fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $symfonyRoot/$symfonyScript;
                fastcgi_param SCRIPT_NAME /app/$symfonyScript;
                fastcgi_param REQUEST_URI /app$uri?$args;
        }


    location / {
        try_files $uri $uri/ /index.php?q=$uri&$args;
    }


    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_param APPLICATION_ENV magana;
        include fastcgi_params;
        fastcgi_read_timeout 600;
        fastcgi_buffers 16 16k;
        fastcgi_buffer_size 32k;
        fastcgi_param SERVER_NAME $folder.magana.dev.hexis.fr;
    }

    location ~ /\.ht {
        deny all;
    }
}
服务器{
听80;
服务器名称~^(?[^.]*)。magana.dev.example.fr;
字符集utf-8;
index.php index.html index.htm;
设置$symfonyRoot/var/www/projects/dev/magana/$folder/htdocs/app/public;
设置$symfonyScript index.php;
root/var/www/projects/dev/magana/$folder/htdocs;
access_log/var/www/projects/dev/magana/$folder/access.log;
error_log/var/www/projects/dev/commons/logs/magana_error.log;
客户最大身体尺寸200M;
位置~*(ogg | ogv | svg | svgz | eot | otf | woff | mp4 | ttf | rss | atom | jpg | jpeg | gif | png | ico | zip | tgz | gz | rar | bz2 | doc s | s | exe | ppt | mid | bmp |$
访问/注销;
未发现注销日志;
过期30天;
添加标题Pragma“public”;
}
位置/应用程序{
根$symfonyRoot;
重写^/app/(.*)$/$1段;
尝试使用文件$uri@symfonyFront;
}
地点@symfonyFront{
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
包括/etc/nginx/fastcgi_参数;
fastcgi_参数脚本_文件名$symfonyRoot/$symfonyScript;
fastcgi_参数脚本_NAME/app/$symfonyScript;
fastcgi_参数请求_URI/app$URI?$args;
}
地点/{
try_files$uri$uri//index.php?q=$uri&$args;
}
位置~\.php${
try_files$uri=404;
fastcgi\u split\u path\u info^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
fastcgi_index.php;
fastcgi\参数脚本\文件名$document\根$fastcgi\脚本\名称;
fastcgi_param应用程序_ENV magana;
包括fastcgi_参数;
fastcgi_读取超时600;
fastcgi_缓冲器16 16k;
fastcgi_缓冲区大小32k;
fastcgi_参数服务器名称$folder.magana.dev.hexis.fr;
}
位置~/\.ht{
否认一切;
}
}

正则表达式位置优先于前缀位置。请使用
^
修饰符。请尝试:
位置^ ~/app{…}
@RichardSmith…我尝试过,但没有成功