How to Run Multiple PHP Versions on Laragon (Windows) Without Breaking Your Projects

The problem: You've got one Laravel project that needs PHP 8.2+, and another older project (maybe a client's legacy site) that only runs on PHP 7.4. Switching Laragon's PHP version to fix one project breaks the other.

Environment: Laragon on Windows 11, multiple Laravel projects with conflicting PHP version requirements

Why It Happens

By default, Laragon runs one global PHP version for everything — whatever you pick from the tray icon menu applies to every single project at once. If Project A needs PHP 8.5 and Project B needs PHP 7.4, there's no version that satisfies both, so switching for one always breaks the other. This isn't a Laragon limitation exactly — it's how Apache's single PHP handler works unless you configure it otherwise.

alt text: "Laragon tray icon PHP version switcher menu"]

The Fix

The real fix is configuring per-site PHP versions using Apache VirtualHost, so each project's .test domain is pinned to its own PHP handler — independent of whatever the global switcher is set to.

1. Install every PHP version you need

In Laragon: right-click tray icon → PHPVersionDownload more.... Install each version your projects require (e.g. 7.4, 8.2, 8.5). This just makes the binaries available — it doesn't assign them yet.

[IMAGE: Laragon's PHP version download/selection screen — alt text: "Laragon download additional PHP version screen"]

2. Find your Apache config for each site

Laragon auto-generates a virtual host config file per project, usually at:

C:\laragon\etc\apache2\sites-enabled\auto.yourproject.test.conf

3. Point that specific site to a specific PHP version

Open the config file and add (or edit) the handler to reference the exact PHP version's php-cgi.exe path:

<VirtualHost *:80>
    ServerName yourproject.test
    DocumentRoot "C:/laragon/www/yourproject/public"

    <Directory "C:/laragon/www/yourproject/public">
        AllowOverride All
        Require all granted
    </Directory>

    <FilesMatch \.php$>
        SetHandler "proxy:fcgi://127.0.0.1:9074"
    </FilesMatch>
</VirtualHost>

The port number (9074 here) corresponds to a specific PHP-FPM instance running that PHP version — Laragon assigns different ports per version internally.

4. Restart Apache

Right-click tray icon → ApacheRestart. Each project now hits its own PHP version regardless of the global switcher.

[IMAGE: Two browser tabs open side by side, each showing phpinfo() with a different PHP version number — alt text: "Two Laravel projects running different PHP versions simultaneously in Laragon"]

Step-by-Step Summary

  1. Install all PHP versions your projects need via Laragon's PHP menu.
  2. Locate each project's auto-generated Apache vhost config.
  3. Set a specific FilesMatch PHP-FPM handler per site, pointing to the right version's port.
  4. Restart Apache.
  5. Verify with <?php phpinfo(); ?> on each project to confirm the correct version loaded.

Don't skip verifying with phpinfo() after this — a misconfigured port number will silently fall back to the global PHP version instead of throwing an obvious error, which makes the mistake easy to miss.

This same approach solves a related headache: Composer dependency conflicts between projects (like needing different ramsey/uuid or brick/math versions) often disappear once each project is properly isolated to its own PHP version — worth checking if that error was actually a version mismatch in disguise.

Stuck on your specific vhost config? Share the details on the Contact page.

Advertisement
Advertisement