简体   繁体   English

浏览器下载 PHP 文件而不是执行它们。 Webmin + Nginx

[英]Browser downloading PHP files instead of executing them. Webmin + NGinx

The Problem问题

I attempted to upgrade from PHP 7.0 to 7.2 today and it resulted in websites on the server downloading through the browser instead of executing like normal.我今天尝试从 PHP 7.0 升级到 7.2,结果导致服务器上的网站通过浏览器下载,而不是正常执行。

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get purge php7.0 php7.0-common
sudo apt-get install php7.2-curl php7.2-xml php7.2-zip php7.2-gd php7.2-mysql php7.2-mbstring

My Question我的问题

Can anyone provide me some examples of how to debug this?谁能给我提供一些如何调试的例子? And any additional insight as to what may be going on?以及关于可能发生的事情的任何其他见解?

My Theory我的理论

Technically I don't know what caused this, but my experience tells me it's one line, in one file, coming from NGinx that needs edited.从技术上讲,我不知道是什么导致了这种情况,但我的经验告诉我,这是一个文件中的一行,来自需要编辑的 NGinx。

What I've Tried我试过的

I found this issue to be commonly reported here on SO.我发现这个问题在 SO 上很常见。 But the solutions have lacked critical information such as the file path, or the file paths they reference don't exist on my system, or the proposed solution doesn't resolve the issue.但是这些解决方案缺少文件路径等关键信息,或者它们引用的文件路径在我的系统上不存在,或者建议的解决方案无法解决问题。

Many articles mentioned configurations for PHP FPM and / or FastCGI.许多文章都提到了 PHP FPM 和/或 FastCGI 的配置。 But I'm unable to identify how to confirm whether or not these are installed / running and what a proper configuration looks like for a standard web server.但是我无法确定如何确认这些是否已安装/正在运行以及标准 Web 服务器的正确配置是什么样的。

What Helped有什么帮助

I did update my /etc/nginx/nginx.conf file from default_type application/octet-stream;我确实从default_type application/octet-stream;更新了我的 /etc/nginx/nginx.conf 文件default_type application/octet-stream; to default_type text/html;default_type text/html; and this has stopped the downloading of files but results in a blank page.这已停止下载文件,但导致空白页面。 Including my phpinfo.php包括我的 phpinfo.php

My Environment我的环境

  • AWS EC2 Small AWS EC2 小型
  • Ubuntu 18.04 Ubuntu 18.04
  • NGinx 1.10.3 NGinx 1.10.3
  • Webmin网络管理员
  • Virtualmin虚拟机

Your domain configuration NGINX ... It's wrong ...你的域配置NGINX...错了...

Missed FastCGI Params ...错过了 FastCGI 参数...

Example:例子:

location ~ [^ /] \. php (/ | $) {
fastcgi_split_path_info ^ (. + \. php) (/.+) $;
fastcgi_index index.php;
fastcgi_pass unix: /var/run/php/php7.2-fpm.sock;
include fastcgi_params;
fastcgi_param PATH_INFO $ fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;
}

Good luck!祝你好运! Send news about your progress ...发送有关您进度的消息...

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

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