1

要升级 cms,我有一个 php 文件,它是一个 phar 文件

https://www.cmsmadesimple.org/downloads/cmsms/

我把它放在我网站的根目录

访问该文件时,会在 url 的末尾添加一个 index.php 像这样:

https://xx.domain.be/cmsms-2.2.12-install.php

变得

https://xx.domain.be/cmsms-2.2.12-install.php/index.php

但是 nginx 给我发了一个错误:没有指定输入文件。

我必须为此网址添加配置,但我不知道是什么

配置 nginx:

server {

       listen 443 ssl;

       server_name xxx.domain.be;

       root /var/www/sites/xxx;

       index index.html index.php;

       location / {
            # This is cool because no php is touched for static content.
            # include the "?$args" part so non-default permalinks doesn't break when using query string
            try_files $uri $uri/ /index.php?$args;
        }

        location ~ \.php$ {
            #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
            include fastcgi.conf;
            fastcgi_intercept_errors on;
            fastcgi_pass php;
            fastcgi_buffers 16 16k;
            fastcgi_buffer_size 32k;
        }
}

谢谢

4

2 回答 2

0

为了修复该特定错误,我需要在 location 块中手动指定 SCRIPT_FILENAME。将一个简单的应用程序打包为 phar 比我预期的更具挑战性。有很多事情可能出错。

我不确定你是如何为你的 phar 服务的。如果您想将 phar 文件从公共根目录与其他静态资产一起提供,您可以。您只需更改 try_files 以尝试使用 phar 文件而不是 index.php,并添加 @symvbean 建议的位置更改。

server {
       listen 443 ssl;
       server_name xxx.domain.tld;

       # root points to the public folder where you put the 
       # phar instead of index.php, let's assume index.phar
       root /var/www/sites/xxx;

       index index.html index.phar;

       location / {
           try_files $uri $uri/ /index.phar;
       }

       location ~ \.phar$ {
           include fastcgi.conf;
       }
}

我一直在将 nginx 配置为服务器 phar 的每个位置,如下所示,但这并不适合提供静态内容。

server {
       listen 443 ssl;
       server_name api.domain.tld;

       # root points to a folder that contains all 
       # deployed phar files
       root /var/www/apps;

       location /v1/service-a {
           include fastcgi.conf;

           # document_root will come from root above
           # we will use a unique phar per service.
           fastcgi_param SCRIPT_FILENAME $document_root/service-a.v1.phar;
       }

       location /v2/service-b {
           include fastcgi.conf;
           fastcgi_param SCRIPT_FILENAME $document_root/service-b.v2.phar;
       }
}
于 2020-01-11T04:08:25.783 回答
0

我看到没有人回答 - 当我遇到你的帖子时,我正在调查同样的问题。虽然我不知道解决方案是什么,但我注意到您的配置仅将 .php 文件移交给 php 解释器。也许您需要添加...

 location ~ \.phar$ {
        include fastcgi.conf;
        fastcgi_intercept_errors on;
        fastcgi_pass php;
        fastcgi_buffers 16 16k;
        fastcgi_buffer_size 32k;
    }

?

于 2020-01-11T01:08:04.140 回答