D
D
Dmitry Sonko2014-10-08 08:36:19
PHP
Dmitry Sonko, 2014-10-08 08:36:19

How to run two frameworks on nginx?

There are two different frameworks for the api system. The old version (1.0, 1.1) was based on the same framework and is located in the v1.0, v1.2 folder relative to the documentroot host. In version 1.2, we plan to transfer some of the functions to one framework, some to another, in version 1.3 we will completely switch to the new one. The question is how to resolve it with a config so that it works out a rewrite. As a result, the static, which lies in the v1.2 folder and requested at rest.ru/1.2/favicon.ico, for example, it does not give out, but tries to send it to the index, and the index is not executed, but is given for download. The current config looks like this:

server {
    listen       80;
    server_name  rest.ru;
    root       /var/www/rest;
    index index.php index.html;	
 
    access_log  /var/logs/rest.access.log  main;

    location / {
       try_files $uri $uri/ @rewrite;
    }

    location @rewrite {
        rewrite ^/(.*)$ /index.php?_url=/$1;
    }

    location ~ \.php {
        set $php_root /var/www/rest;

        if ($request_uri ~ /1.2/){
            set $php_root /var/www/rest/v1.2/public;
        }

        #try_files      $uri = 404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;

        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
        fastcgi_param SCRIPT_FILENAME $php_root$fastcgi_script_name;
        fastcgi_param  APPLICATION_ENV development;
        include        fastcgi_params;
    }

    location /1.2/ {
        alias /var/www/rest/v1.2/public/;
    }
}

I will be grateful for help

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question