1

I want to use PHP 7 with newer apps and PHP 5.6 with apps, that doesn't work with PHP 7. So I try to configure Nginx to enable different PHP versions for different pathes. But it doesn't work:

 # should enable PHP5 for all PHP-scripts under /vexim/ path
 location ^~ /vexim/.*\.php$ {
     include snippets/fastcgi-php.conf;
     fastcgi_pass unix:/var/run/php5-fpm.sock;
 }

And the default for anything else should be PHP 7:

location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}

With this configuration PHP scripts under /vexim/ are not parsed at all. How to get this working with different pathes and PHP versions?

(Using Debian 8.3 Jessie, Nginx 1.8.1 (dotdeb), PHP 5.6, PHP 7 (dotdeb))

1 Answer 1

2

location ^~ is not a regex location, it is a prefix location that takes precedence over all regex locations.

See this document for details.

What you probably want is:

location ~ ^/vexim/.*\.php$ { ... }
location ~ \.php$ { ... }

Make sure that the /vexim location comes first as regex locations are ordered.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .