在nginx中同时使用不同版本的php

ctehm74n  于 2023-05-22  发布在  Nginx
关注(0)|答案(1)|浏览(129)

我有两个应用程序:一个写在php5.5上,另一个写在php8.0上。当我尝试在nginx中设置分离的php-cgi块时-所有请求都由php5.5处理。看起来php5.5定义覆盖了php8.0或idk

server
{
  listen 80 default_server;
  listen [::]:80 default_server;
  server_name $NGINX_HOST;

  index index.php index.html;
  error_log /var/log/nginx/error.log;
  access_log /var/log/nginx/access.log;

  root /var/www/html;
  location ~ ^/reports
  {
    #root /var/www/html;
    alias /var/www/html/;
    try_files $uri =404;
    location ~ \.php$
    {
      fastcgi_pass php8.0:9000;

      fastcgi_split_path_info ^(.+\.php)(/.+)$;
      fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
      include fastcgi_params;
    }
  }

  location /
  {
    alias /var/www/html/oldSystem;
    try_files $uri /index.php;
    location ~ \.php$
    {
      fastcgi_pass php5.5:9000;

      fastcgi_split_path_info ^(.+\.php)(/.+)$;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      include fastcgi_params;
    }
  }

}

我尝试使用继承位置,移动位置和做其他东西没有任何效果

gwbalxhn

gwbalxhn1#

还有日志中的错误:

nginx: [emerg] location "/" is outside location "//reports" in /etc/nginx/conf.d/default.conf:14
nginx: [emerg] location "/" is outside location "//reports" in /etc/nginx/conf.d/default.conf:14
nginx: [emerg] location "/" is outside location "//reports" in /etc/nginx/conf.d/default.conf:14
nginx: [emerg] location "/" is outside location "//reports" in /etc/nginx/conf.d/default.conf:14
nginx: [emerg] location "/" is outside location "//reports" in /etc/nginx/conf.d/default.conf:14
nginx: [emerg] location "/" is outside location "//reports" in /etc/nginx/conf.d/default.conf:14
nginx: [emerg] location "/" is outside location "//reports" in /etc/nginx/conf.d/default.conf:14
nginx: [emerg] location "/" is outside location "//reports" in /etc/nginx/conf.d/default.conf:14
nginx: [emerg] location "\.php$" cannot be inside the exact location "/reports" in /etc/nginx/conf.d/default.conf:30
nginx: [emerg] location "\.php$" cannot be inside the exact location "/reports" in /etc/nginx/conf.d/default.conf:30
nginx: [emerg] location "\.php$" cannot be inside the exact location "/reports" in /etc/nginx/conf.d/default.conf:30
nginx: [emerg] location "\.php$" cannot be inside the exact location "/reports" in /etc/nginx/conf.d/default.conf:30

相关问题