[英]NGINX only executing “index.php” but not any other “*.php” files
I'm trying to setup a CMS to run it's installation.我正在尝试设置一个 CMS 来运行它的安装。 The installation files are a setup folder and a file called "setup.php".
安装文件是一个安装文件夹和一个名为“setup.php”的文件。 If I access my website at "example.com/setup.php" it tries to download the file, but if I rename "setup.php" to "index.php" and navigate to "example.com/index.php" or just "example.com" it executes the php file.
如果我在“example.com/setup.php”访问我的网站,它会尝试下载文件,但如果我将“setup.php”重命名为“index.php”并导航到“example.com/index.php”或只是“example.com”,它执行 php 文件。
My nginx config for the site is this:我的站点的 nginx 配置是这样的:
server {
root /var/www/example.com;
index index.php index.html index.htm;
server_name example.com;
listen [::]:443 ssl; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
location / { try_files $uri $uri/ /index.php?$query_string; }
# Pass the PHP scripts to FastCGI server
location ~ ^/index.php {
# Write your FPM configuration here
include snippets/fastcgi-php.conf;
#fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php-fpm.sock;
#fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#include fastcgi_params;
}
# Whitelist
## Let TastyIgniter handle if static file does not exists
location ~ ^/favicon\.ico { try_files $uri /index.php; }
location ~ ^/sitemap\.xml { try_files $uri /index.php; }
location ~ ^/robots\.txt { try_files $uri /index.php; }
location ~ ^/humans\.txt { try_files $uri /index.php; }
## Let nginx return 404 if static file does not exists
location ~ ^/assets/media { try_files $uri 404; }
location ~ ^/storage/temp/public { try_files $uri 404; }
location ~ ^/app/.*/assets { try_files $uri 404; }
location ~ ^/app/.*/actions/.*/assets { try_files $uri 404; }
location ~ ^/app/.*/dashboardwidgets/.*/assets { try_files $uri 404; }
location ~ ^/app/.*/formwidgets/.*/assets { try_files $uri 404; }
location ~ ^/app/.*/widgets/.*/assets { try_files $uri 404; }
location ~ ^/extensions/.*/.*/assets { try_files $uri 404; }
location ~ ^/extensions/.*/.*/actions/.*/assets { try_files $uri 404; }
location ~ ^/extensions/.*/.*/dashboardwidgets/.*/assets { try_files $uri 404; }
location ~ ^/extensions/.*/.*/formwidgets/.*/assets { try_files $uri 404; }
location ~ ^/extensions/.*/.*/widgets/.*/assets { try_files $uri 404; }
location ~ ^/themes/.*/assets { try_files $uri 404; }
}
server {
if ($host = example.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name example.com;
return 404; # managed by Certbot
}
I changed the web address in the config before posting for security reasons.出于安全原因,我在发布之前更改了配置中的 web 地址。 I'm extremely confused as to why this isn't working as if index.php executes, all.php files should.
我非常困惑为什么这不起作用,好像 index.php 执行,all.php 文件应该。 Any help in figuring this out would be appreciated.
任何帮助弄清楚这一点将不胜感激。
I'm an idiot and have had a long day.我是个白痴,度过了漫长的一天。
location ~ ^/index.php {
should be应该
location ~ /.php {
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.