在子文件夹中为 PHP 配置 nginx

在子文件夹中为 PHP 配置 nginx

我希望提供一个位于文件夹中的旧应用程序 - 该文件夹包含所需的一切 - index.html,各种.js和“server.php”后端。index.html 运行良好,但我对 server.php 的调用得到 404。

我的配置:

server {
    listen 443;
    server_name server.xxx;

    ssl on;
    ssl_dhparam /etc/nginx/ssl/dhparam.pem;
    ssl_certificate /etc/nginx/ssl/greenmapp.eu.chained.crt;
    ssl_certificate_key /etc/nginx/ssl/greenmapp.eu.key;

    include /etc/nginx/conf/ssl.conf;

    include /etc/nginx/conf/rest.v2.conf;

    root /var/lib/treemapp/node/v3.3/;

    index index.html;

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

    location @rewrites {
            rewrite ^(.+)$ /index.html last;
    }


    location /app {
        alias /var/www/v3.1.3/www/; #this works, 
    }

    location /app/server.php { # This doesn't work - I get 404
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
    }
}

php 配置在我的另一个配置中起作用,该配置针对指向同一物理文件夹的不同主机名。

该怎么办?

相关内容