Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

aarontharker's avatar

Nginx - php being served as downloads not executes after downgrading PHP because of http/2

I have a site that has been working fine for months but I had to downgraded from php 8.2 to php 8.1 as a new package I want to install doesn't support 8.2. My Nginx config hasn't changed and I've checked that php is running on 127.0.0.1:9000 same as before but I can't get it to execute php rather than downloading it. My Nginx config is as follows

worker_processes  1;
load_module modules/ngx_http_brotli_filter_module.so;
load_module modules/ngx_http_brotli_static_module.so;

events {
    worker_connections  1024;
}
http {
    include       mime.types;
    sendfile        on;
    keepalive_timeout  65;

    server {
        listen 80 http2 default_server;
        server_name _;
        root /app/public;

        add_header X-Frame-Options "SAMEORIGIN";
        add_header X-Content-Type-Options "nosniff";
        
        index index.php;
        charset utf-8;
        location / {
            try_files $uri $uri/ /index.php?$query_string;
        }

        location = /favicon.ico { access_log off; log_not_found off; }
        location = /robots.txt  { access_log off; log_not_found off; }
        access_log /dev/stdout;
        error_log /dev/stderr;
        sendfile off;
        client_max_body_size 200m;
        brotli on;
        brotli_static on;
        brotli_types *;

        location ~ \.php$ {
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params; 
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }
}

daemon off;

and if I test php-fpm

/var # cgi-fcgi -bind -connect 127.0.0.1:9000
X-Powered-By: PHP/8.1.15
Content-type: text/html; charset=UTF-8

which says to me the php is listening on the correct port. Can anyone see what is going wrong? There is nothing being logged in the error logs to give me any clue either

0 likes
1 reply
aarontharker's avatar

ok so I have tracked the issue down to an issue with http2. Anyone have any ideas why 8.1.15 won't work over http2 but 8.2.1 did?

Please or to participate in this conversation.