1

I need to install PHP 7.2 on a Ubuntu 16.04.6 LTS server running PHP 7.0 with fpm.

I've installed php7.2, php7.2-fpm, enabled the module, disabled 7.0, set the alternatives

/etc/alternatives/php -> /usr/bin/php7.2
/etc/alternatives/php-cgi -> /usr/bin/php-cgi7.2
/etc/alternatives/php-cgi-bin -> /usr/lib/cgi-bin/php7.2
/etc/alternatives/php-fpm.sock -> /run/php/php7.2-fpm.sock

If I stop or uninstall php7.0-fpm and use php7.2-fpm I'm getting a 502 bad gateway error If I restart php7.0-fpm 502 bad gateway error disappear but PHP 7.0.33 is loaded

Apache version is: Apache/2.4.18 (Ubuntu)

Configuration

<IfModule !mod_php7.c>
<IfModule proxy_fcgi_module>
    <IfModule setenvif_module>
    SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
    </IfModule>

    <FilesMatch ".+\.ph(ar|p|tml)$">
        SetHandler "proxy:unix:/run/php/php7.2-fpm.sock|fcgi://localhost"
    </FilesMatch>
    <FilesMatch ".+\.phps$">
        # Deny access to raw php sources by default
        # To re-enable it's recommended to enable access to the files
        # only in specific virtual host or directory
        Require all denied
    </FilesMatch>
    # Deny access to files without filename (e.g. '.php')
    <FilesMatch "^\.ph(ar|p|ps|tml)$">
        Require all denied
    </FilesMatch>
</IfModule>
</IfModule>

What am I missing?

SimoneB
  • 592
  • 1
  • 6
  • 16

2 Answers2

0

If your php_mod works correctly, you didn't load the proxy_fcgi_module Module. You must remove the <IfModule !mod_php7.c> around the <IfModule proxy_fcgi_module> like this config.

<IfModule !mod_php7.c>
</IfModule>

<IfModule proxy_fcgi_module>
    <IfModule setenvif_module>
    SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
    </IfModule>

    <FilesMatch ".+\.ph(ar|p|tml)$">
        SetHandler "proxy:unix:/run/php/php7.2-fpm.sock|fcgi://localhost"
    </FilesMatch>
    <FilesMatch ".+\.phps$">
        # Deny access to raw php sources by default
        # To re-enable it's recommended to enable access to the files
        # only in specific virtual host or directory
        Require all denied
    </FilesMatch>
    # Deny access to files without filename (e.g. '.php')
    <FilesMatch "^\.ph(ar|p|ps|tml)$">
        Require all denied
    </FilesMatch>
</IfModule>
SubCore
  • 373
  • 2
  • 7
0

Ok, I discovered the issue.

On the server there is Cady configured and in /etc/caddy/Caddyfile php fpm was set to 7.0

I've solved symlinking php7.0 to 7.2 in /run/php to not have to mess with the Caddyfile.

SimoneB
  • 592
  • 1
  • 6
  • 16