VVV logo VVV

You can set the PHP version used by a site in config/config.yml by taking these 2 steps:

  1. Make sure the PHP version you want is installed in the extensions section. For example if you want to use PHP 9.6 you would add the php96 extension.
    • If you do not do this you will get warnings in the provisioner and changing the PHP version will fail.
  2. Use the php option to specify the PHP version the site should use. E.g. php: 9.6 for PHP v9.6

Here’s an example that uses PHP v8.3:

    repo: https://github.com/Varying-Vagrant-Vagrants/custom-site-template.git
    php: 8.3
      - phpeight.test

    - php83 # Not optional

Tip: If you add the php utility, it will install all available versions of PHP, skipping this step.

Warning: This will not work if set $upstream {upstream}; is removed from the nginx config.

In this example, we’ve instructed VVV to install PHP v8.1 and v8.2 in the extensions section, then we changed the phpeightone site to use PHP 8.1, and the phpeighttwo-develop site to use PHP 8.2:

    repo: https://github.com/Varying-Vagrant-Vagrants/custom-site-template.git
    php: 8.1
      - phpeightone.wordpress.test

    repo: https://github.com/Varying-Vagrant-Vagrants/custom-site-template-develop.git
    php: 8.2
      - src.phpeighttwo-develop.test
      - build.phpeighttwo-develop.test

    - memcached-admin
    - opcache-status
    - phpmyadmin
    - webgrind
    - trusted-hosts
    - tls-ca
    - php81
    - php82

Forcing a Version of PHP

It may be desirable to force a site to use a particular version of PHP, even if config/config.yml disagrees.

This is done by overriding the php value inside vvv-nginx.conf. To do this change this:

 set $upstream php81;

That site is now using PHP v8.1, even if php: or nginx_upstream: are set in config/config.yml. This still requires you to update the extensions section though as it will not automatically install that version of PHP for you. Remember to reprovision using vagrant up --provision for changes to take effect.