简体   繁体   English

nginx 正在下载一些文件而不是执行它们

[英]nginx is downloading some files instead of executing them

For some reason, my nginx installation is running some .php files properly, while doesn't.出于某种原因,我的 nginx 安装正确运行了一些.php文件,而没有。

I have some files:我有一些文件:

  • upload.php, sig.php, popup.php - executes and works. upload.php、sig.php、popup.php - 执行和工作。
  • asdfsda.php - doesn't work, when I visit it, the file downloads. asdfsda.php - 不起作用,当我访问它时,文件会下载。
  • (SOLVED by clearing browser cache) visiting my domain - downloads my index.html file with the name "download", when I visit mydoma.in/index.html, I can see my index file properly. (通过清除浏览器缓存解决)访问我的域 - 下载名为“download”的 index.html 文件,当我访问 mydoma.in/index.html 时,我可以正确地看到我的索引文件。

I have no idea what could cause this issue.我不知道是什么导致了这个问题。

I tried:我试过:

  • reinstalling PHP5-FPM重新安装 PHP5-FPM
  • restarting the server重新启动服务器
  • restarting nginx/php5-fpm services重启 nginx/php5-fpm 服务
  • chmod files to 777 chmod 文件到 777

Related nginx config part:相关的 nginx 配置部分:

root /boot/www;

index index.html index.php;

server_name - my domain here -;

location / {
    try_files $uri $uri/ =404;
}

location /upload.php {
    include php5.conf;
}

location /asdfsda.php {
    include php5.conf;
}

location /popup.php {
    include php5.conf;
}

location /sig.php {
    include php5.conf;
}

php5.conf: php5.conf:

fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;

This issue started today, I didn't change anything in my config files recently.这个问题从今天开始,我最近没有更改配置文件中的任何内容。
It worked fine yesterday.昨天效果很好。

I'll appreciate any help, thanks!我将不胜感激任何帮助,谢谢!

UPDATE: If I change the name of asdfsda.php file that doesn't execute to something else, it actually does execute.更新:如果我将不执行的asdfsda.php文件的名称更改为其他名称,它实际上会执行。 For example, I renamed it to d.php and changed the config entry from asdfsda to d and it executed.例如,我将其重命名为d.php并将配置条目从asdfsdad并执行。
What is wrong?怎么了?

Why not use this?为什么不使用这个?

location ~ ^/(upload|asdfsda|popup|sig)\.php$ {
    fastcgi_index   index.php;
    fastcgi_pass    unix:/var/run/php5-fpm.sock;
    fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include         /etc/nginx/fastcgi_params;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM