DEV Community

Discussion on: Work and play in PHP 7.4 & PHP 8.0

Collapse
 
lito profile image
Lito

To test a project at same time with multiple PHP versions I have a default virtualhost with project name and version alias:

<VirtualHost _default_:80>
    ServerName project.localhost
    ServerAlias php74.project.localhost

    DocumentRoot /var/www/project/public

    <FilesMatch \.php$>
        SetHandler "proxy:unix:/var/run/php/php7.4-fpm.sock|fcgi://localhost"
    </FilesMatch>
</VirtualHost>
Enter fullscreen mode Exit fullscreen mode

And a second virtualhost with each other version to test:

<VirtualHost _default_:80>
    ServerName php80.project.localhost

    DocumentRoot /var/www/project/public

    <FilesMatch \.php$>
        SetHandler "proxy:unix:/var/run/php/php8.0-fpm.sock|fcgi://localhost"
    </FilesMatch>
</VirtualHost>
Enter fullscreen mode Exit fullscreen mode

You should remember to add this hosts to your /etc/hosts file:

127.0.0.1 project.localhost php74.project.localhost php80.project.localhost
Enter fullscreen mode Exit fullscreen mode

Cheers!