Sudden site permission errors, php-fpm running as www-data (SOLVED)

Ubuntu 20.04.1

Sites on my Ubuntu servers suddenly started logging file permission errors. phpinfo() showed they were running under www-data instead of the virtual server owner user. Tracked the problem down to a new version of /etc/apache2/conf-available/php7.4-fpm.conf installed on 2021-02-14. The new file puts the SetHandler directive in an If clause:

<If "-f %{REQUEST_FILENAME}">
    SetHandler "proxy:unix:/run/php/php7.4-fpm.sock|fcgi://localhost"
</If>

Removing the If lines solved the problem.

This was a tricky one to figure out, so I thought I’d post it for the benefit of others.

2 Likes

Just had the same issue and removed the whole config file Unable to change PHP version

PHP maintainers appear to have fixed this problem in the latest update, released yesterday. The If clause is gone.

Removing the file means it will come back when the package is updated. Editing it will leave it alone in some modes (depends on your choices with regard to how dpkg handles config files, but the default is to leave them alone).

1 Like

I actually removed the symbolic link in conf-enabled folder, not the actual conf file in conf-available. Updating the package shouldn’t create a new symbolic link I think.

As the php handler is set per virtual host, isn’t these apache fpm config files unnecessary?

1 Like