phpapacheubuntu-18.04fpm

two versions of PHP on the same Ubuntu 18.04 server with Apache


I have a server with Ubuntu 18.04 on which I host two applications, one works with PHP 7.0 and the other with PHP 8.0. I have followed several guides where they explain in detail what to do with PHP-FPM and I do all the steps correctly without throwing errors but when checking in the browser it shows me version 8.0 for both. Could you help me with this?” Is there anything else you would like to know?

these are the virtual hosts

<VirtualHost *80:>
    ServerName certificacion.local
    DocumentRoot /var/www/certificacion.local

    <Directory /var/www/certificacion.local>
        Options -Indexes +FollowSymLinks
        AllowOverride All
    </Directory>

    ProxyPassMatch "^/(.*\.php(/.*)?)$" "unix:/run/php/php7.0-fpm.sock|fcgi://localhost/var/www/certificacion.local"

    ErrorLog ${APACHE_LOG_DIR}/certificacion.local-error.log
    CustomLog ${APACHE_LOG_DIR}/certificacion.local-access.log combined
</VirtualHost>

<VirtualHost *:80>
    ServerName fiscalizacion.local
    DocumentRoot /var/www/fiscalizacion.local

    <Directory /var/www/fiscalizacion.local>
        Options -Indexes +FollowSymLinks
        AllowOverride All
    </Directory>

    ProxyPassMatch "^/(.*\.php(/.*)?)$" "unix:/run/php/php8.0-fpm.sock|fcgi://localhost/var/www/fiscalizacion.local"

    ErrorLog ${APACHE_LOG_DIR}/fiscalizacion.local-error.log
    CustomLog ${APACHE_LOG_DIR}/fiscalizacion.local-access.log combined
</VirtualHost>`

i tried to configure PHP-FPM


Solution

  • That's how it works for me

    <VirtualHost *:80>
        DocumentRoot "/var/www/qa-laravel/public"
            ServerName .....local
            <Directory "/var/www/qa-laravel/public">
                    AllowOverride All
                    Options Indexes FollowSymLinks
                    Order allow,deny
                    Allow from all
            </Directory>
                 <FilesMatch \.php$>
                        SetHandler "proxy:unix:/run/php/php7.4-fpm.sock|fcgi://localhos>
                </FilesMatch>
        
        </VirtualHost>
    

    Check PHP-FPM service: Confirm that the PHP-FPM services for both PHP versions are running properly.

     service php7.0-fpm status
     service php8.0-fpm status