要升级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;
}
}
谢谢
我没有人回答-当我遇到您的帖子时,我正在调查相同的问题。虽然我不知道解决方案是什么,但是我注意到您的配置仅将.php文件交给了php解释器。也许您需要添加...
location ~ \.phar$ {
include fastcgi.conf;
fastcgi_intercept_errors on;
fastcgi_pass php;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
}
?
为了解决该特定错误,我需要在位置块中手动指定SCRIPT_FILENAME。将一个简单的应用程序打包为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;
}
}