Multiple PHP version on CentOS 7 still using the default

248 views Asked by At

I am trying to setup my server (centos7) to have multiple php versions and found this guide on google. Everything works except that the website I am trying to run with php8.2 still using the default which is php7.1.

Is there anything that I missed looking? Or any command that I can use to troubleshoot?

Check list

PHP-FPM

  • sudo systemctl status php71-php-fpm - good and running @ port 9071
  • sudo systemctl status php82-php-fpm - good and running @ port 9082

Virtual Host

<VirtualHost *:80>
<Directory /DATA1/www/php82-custom.com>
    Order allow,deny
    Allow from all
    Require all granted
    AllowOverride All
</Directory>
    ServerName php82-custom.com
    DocumentRoot /DATA1/www/php82-custom.com
    DirectoryIndex info.php
    SetHandler "proxy:fcgi://127.0.0.1:9082"
    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
    Action php82-fcgi /cgi-bin/php82.fcgi
    ErrorLog /DATA1/www/log/php82-custom.com
    CustomLog /DATA1/www/log/php82-custom.com-access_log combined
</VirtualHost>

enter image description here

1

There are 1 answers

3
hassan On BEST ANSWER

The SetHandler directive is a Directory || Location scoped directive.

You will need to move it inside your directory directive:

SetHandler Directive

When placed into an .htaccess file or a or section, this directive forces all matching files to be parsed through the handler given by handler-name

In your case, you need to:

<VirtualHost *:80>
<Directory /DATA1/www/php82-custom.com>
    Order allow,deny
    Allow from all
    Require all granted
    AllowOverride All
    <FilesMatch \.php$>
        SetHandler "proxy:unix:/run/php/php8.2-fpm.sock|fcgi://127.0.0.1:9082"
    </FilesMatch>
</Directory>
    ServerName php82-custom.com
    DocumentRoot /DATA1/www/php82-custom.com
    DirectoryIndex info.php
    ErrorLog /DATA1/www/log/php82-custom.com
    CustomLog /DATA1/www/log/php82-custom.com-access_log combined
</VirtualHost>