Out of the box Varying Vagrant Vagrants lets you define a PHP version to use for each site you’re adding to the configuration file. What this doesn’t do is change the PHP version that WP CLI uses when you use
vagrant ssh to log into the sites you’ve just created. Unless you take an extra step WP CLI will continue to use the default PHP version for VVV.
Installing Other PHP Versions
~/vvv-local/config/config.php file you’ll see a section that looks like this.
# Extensions https://varyingvagrantvagrants.org/docs/en-US/utilities/ # are system level items that aren't websites, that install tools or packages # the core extensions install tools such as phpmyadmin or new PHP versions # # these used to be called utilities but people kept requesting # extensions not realising so it was renamed extensions: core: # The core VVV extensions - tls-ca # HTTPS SSL/TLS certificates - phpmyadmin # Web based database client #- memcached-admin # Object cache management #- opcache-status # opcache management #- webgrind # PHP Debugging #- mongodb # needed for Tideways/XHGui #- tideways # PHP profiling tool, also installs xhgui check https://varyingvagrantvagrants.org/docs/en-US/references/tideways-xhgui/ #- nvm # Node Version Manager #- php56 #- php70 #- php71 #- php72 #- php73 #- php74 - php80 - php81 - php82
Note at the bottom of the section of code I’ve removed the comments on PHP 8.0, 8.1, and 8.2. By doing this I’ve asked VVV to install those versions of PHP when it provisions.
Setting PHP Version for WP CLI
Now we need to log into VVV with
vagrant ssh. To see which versions of PHP you have available navigate to
/usr/bin. Then I usually type
php and hit the
tab key twice to try and autocomplete the command. Since there are many things starting with
php terminal shows me a bunch of options.
Now I need to set the version of PHP I want to use with
sudo update-alternatives --set php /usr/bin/php8.0 if I want to use 8.0. This sets the default
php call to the version of PHP you want to use for a site.
Now in the documentation for changing PHP versions in VVV there is a troubleshooting section at the bottom that talks about changing the value in
vvv.nginx.conf file, but as with much documenation…it doesn’t tell you where that file is and I can’t find it. Ideally I’d change the default PHP version to 8.2 as it’s the most current version, but after looking through the docs a few times…there aren’t clear instructions on it.
If I do figure this out, I’ll update the documentation so that everyone can benefit from clear obvious documentation.