Php phar nginx未指定输入文件

Php phar nginx未指定输入文件,php,nginx,phar,cmsmadesimple,Php,Nginx,Phar,Cmsmadesimple,为了升级cms,我有一个php文件,它是一个phar文件 () 我把它放在我网站的根上 访问该文件时,会在url的末尾添加index.php 就像这样: 变成 但是nginx向我发送了一个错误:没有指定输入文件 我必须为这个url添加一个配置,但我不知道是什么 配置nginx: server { listen 443 ssl; server_name xxx.domain.be; root /var/www/sites/xxx;

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

()

我把它放在我网站的根上

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

变成

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

我必须为这个url添加一个配置,但我不知道是什么

配置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;
        }
}

谢谢你

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

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

我发现没有人回答-我在调查同样的问题时看到了你的帖子。虽然我不知道解决方案是什么,但我注意到您的配置只会将.php文件交给php解释器。也许你需要补充

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

为了修复该特定错误,我需要在位置块中手动指定脚本文件名。将一个简单的应用程序打包为phar远比我想象的更具挑战性。有太多的事情会出错

我不知道你是如何为你的药剂师服务的。如果您希望将phar文件与其他静态资产一起从公共根目录中提供服务,则可以。您只需更改try_文件以尝试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;
       }
}

为了修复这个特定的错误,我需要在location块中手动指定SCRIPT_文件名。将一个简单的应用程序打包为phar远比我想象的更具挑战性。有太多的事情会出错

我不知道你是如何为你的药剂师服务的。如果您希望将phar文件与其他静态资产一起从公共根目录中提供服务,则可以。您只需更改try_文件以尝试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;
       }
}