VVV logo VVV

You can set the PHP version in config/config.yml when defining a site. To do this, use the php option to specify the PHP version in Nginx and the provisioner. VVV also needs to be told to install that version of PHP using the extensions section.

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

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

extensions:
  core:
    - php80

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 have changed the phpeightone site to use PHP 8.1, and the phpeighttwo-develop site to use PHP 8.2:

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

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

extensions:
  core:
    - 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.

Troubleshooting