Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to setup a symfony2 app in a subdirectory of our Server

Webserver: nginx 1.1.6 + php fpm OS: gentoo

my target is to get the app working from a subdirectory

subdomain.xy.domain.tld/tool

my nginx config looks like that

server  {

    listen          80;
    server_name     subdomain.xy.domain.tld;

    error_log       /var/log/nginx/subdomain.xy.error.log info;
    access_log      /var/log/nginx/subdomain.xy.access.log main;


    location /tool {

        root /var/www/vhosts/subdomain.xy/tool/web;

        index app.php;

        location ~ \.php($|/) {
            include fastcgi_params;

            set $script $uri;
            set $path_info "";

            if ($uri ~ "^(.+\.php)($|/)") {
                set $script $1;
            }

            if ($uri ~ "^(.+\.php)(/.+)") {
                set $script $1;
                set $path_info $2;
            }

            fastcgi_param SCRIPT_FILENAME /var/www/vhosts/subdomain.xy/tool/web$fastcgi_script_name;
            #fastcgi_intercept_errors on;
            fastcgi_pass 127.0.0.1:9000;

            fastcgi_param SCRIPT_NAME $script;
            fastcgi_param PATH_INFO $path_info;
        }
    }

}

I have really no clue how to do this... I've searched the web for hours and tried dozens of different configs but nothing worked. I hope someone has an idea =)

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Found the solution maybe it helps somebody else

server {
listen          80;
server_name     domain.xy;

error_log       /var/log/nginx/domain.xy.error.log info;
access_log      /var/log/nginx/domain.xy.access.log main;

root /var/www/vhosts/domain.xy;

location /tool {
    alias /var/www/vhosts/domain.xy/tool/web;
    index app.php;
        if (-f $request_filename) {
             break;
        }
        rewrite ^(.*)$ /tool/app.php last;
}

location ~ /tool/(.+)\.php(/|$) {
    set $script $uri;

        if ($uri ~ "/tool/(.+\.php)(/|$)") {
            set $script $1;
    }

    fastcgi_pass backend;
    include fastcgi_params;
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    fastcgi_param  SCRIPT_FILENAME  $document_root/tool/web/$script;
}

}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.