Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

GodziLaravel's avatar

How to change PHP version in homestead

After doing the vagrant up, when I check the php version :

php -v
PHP 7.3.2 (cli) (built: Feb  5 2019 23:16:38) ( ZTS MSVC15 (Visual C++ 2017) x86 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.2, Copyright (c) 1998-2018 Zend Technologies

Homestead.yaml:

ip: 192.168.10.10
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
    - ~/.ssh/id_rsa
folders:
    -
        map: 'C:\Users\mabdella\Codes\HighAxions'
        to: /home/vagrant/code
sites:
    -
        map: highaction.test
        to: /home/vagrant/code/public
        php: "5.6"
databases:
    - homestead
name: highaxions
hostname: highaxions

As you can see event the php version value is 5.6 I still have that problem !

0 likes
9 replies
mushood's avatar

If i'm not wrong, you have to run "vagrant provision" first when you make such changes

2 likes
tomopongrac's avatar

Connect to homestead with ssh

vagrant ssh

and write command bellow

php56

if you want php 7.3 again write this command

php73
23 likes
Cronix's avatar

Almost what @tomopongrac said. It's in the docs: https://laravel.com/docs/5.8/homestead#multiple-php-versions

There are multiple versions of php installed. When specifying the version in the homestead.yaml file, that makes it so when you access the site via a browser, it is being executed as that php version (5.6 in your case). That does not instruct it to use php 5.6 on the cli, so when you check the version with php -v, it will give the systemwide version. If you want to access other versions via the cli, you have to use their proper names in shell instead of just php {command}, like php5.6 {command}

system wide version

vagrant@homestead:~$ php -v
PHP 7.3.4-1+ubuntu18.04.1+deb.sury.org+3 (cli) (built: Apr 10 2019 10:51:11) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.4, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.4-1+ubuntu18.04.1+deb.sury.org+3, Copyright (c) 1999-2018, by Zend Technologies
    with blackfire v1.24.4~linux-x64-non_zts73, https://blackfire.io, by Blackfire

specific version (7.1)

vagrant@homestead:~$ php7.1 -v
PHP 7.1.28-1+ubuntu18.04.1+deb.sury.org+3 (cli) (built: Apr 10 2019 10:50:29) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.1.28-1+ubuntu18.04.1+deb.sury.org+3, Copyright (c) 1999-2018, by Zend Technologies
    with blackfire v1.24.4~linux-x64-non_zts71, https://blackfire.io, by Blackfire

Don't forget to run vagrant reload --provision after you make changes to your homestead.yaml file.

3 likes
sumanb's avatar

This actually fixed. Saved my day. Thanks

Jimmyboro's avatar

@omniware Thank you! Ive been running around like crazy trying to change this! Its nowonder im going bald!

1 like
gliga24's avatar
vagrant ssh
php56

This will change php CLI version, but not php FPM version. So, if you run php -v you'll see it's showing version 5.6. However, when you write phpinfo() under your app and run from browser you'll get version 7.3.

Ivans84's avatar

Thank you so much, mate. You are my lifesaver! :)))

Please or to participate in this conversation.