I
I
Igor A2020-02-09 13:21:33
Nginx
Igor A, 2020-02-09 13:21:33

nginx routing. php7.0-fpm and php7.3-fpm on the same host?

There is a YII framework for which all requests to the web server are processed by one index.php file.
The task was to add api to the project without a third-party host. Those. when accessing the same domain /api/(parameters)*,
for example, run another version of php with a different www folder.
How to implement it?

Fragment of nginx config

location ~ \.php {
        client_max_body_size 8m;
        client_body_buffer_size 128k;
        fastcgi_split_path_info  ^(.+\.php)(.*)$;
        set $fsn /index.php;
        if (-f $document_root$fastcgi_script_name){
            set $fsn $fastcgi_script_name;
        }
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        include fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fsn;
        fastcgi_param  PATH_INFO        $fastcgi_path_info;
        fastcgi_param  PATH_TRANSLATED  $document_root$fsn;
        #fastcgi_param REQUEST_URI      $request_url;
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
ky0, 2020-02-09
@ky0

You just make two sockets - each for its own version and specify them in the necessary locations. In the config (if necessary), also fastcgi_paramspost `s.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question