2

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.

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.

What I've Tried

I found this issue to be commonly reported here on 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. 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.

What Helped

I did update my /etc/nginx/nginx.conf file from default_type application/octet-stream; to default_type text/html; and this has stopped the downloading of files but results in a blank page. Including my phpinfo.php

My Environment

  • AWS EC2 Small
  • Ubuntu 18.04
  • NGinx 1.10.3
  • Webmin
  • Virtualmin
Spencer Hill
  • 1,043
  • 2
  • 15
  • 38
  • I got the same problem a few times in an apache envirement. I don't know alot about nginx thought but check the vhost file and also your htaccess. Most of the time thats where the problem is. – Patrick Simard Nov 20 '18 at 00:23
  • Thanks but only Apache uses .htaccess and I'm running NGinx which uses a global and site specific nginx.conf file. – Spencer Hill Nov 20 '18 at 00:25
  • Could you elaborate on what you mean by checking my vhosts file? – Spencer Hill Nov 20 '18 at 00:25
  • try this: https://stackoverflow.com/questions/25591040/nginx-serves-php-files-as-downloads-instead-of-executing-them – Patrick Simard Nov 20 '18 at 00:27
  • It probably has to do with how you reference the PHP compiler in your config files but like I said I am no nginx expert. Seems like your PHP files are executed instead of being send to the compiler. – Patrick Simard Nov 20 '18 at 00:30
  • Thanks, my settings already matched the ones advised in the post so unfortunately it didn't help. – Spencer Hill Nov 20 '18 at 00:35
  • 1
    Sorry bro. Try posting your question at https://serverfault.com instead. stackoverflow is more suited for programing questions then server problems. – Patrick Simard Nov 20 '18 at 00:56
  • Np bro good luck ;-) I actualy have an active post there my self hehe – Patrick Simard Nov 20 '18 at 01:04

1 Answers1

0

Your domain configuration NGINX ... It's wrong ...

Missed FastCGI Params ...

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 ...

Paulo Boaventura
  • 1,365
  • 1
  • 9
  • 29