I am trying to make a vagrant homestead server for Laravel 5.4.36. So that I can practice upgrading my main website to the latest laravel version locally.
The server starts up correctly, but I am expecting/need PHP version 7.0. Instead I get version 7.2.3 when I type “php –version” in the SSH terminal. The documentation says that homestead 5.2.0 SHOULD install PHP version 7.0, but it’s not. (https://laravel.com/docs/5.2/homestead)
Typing “php artisan –version” returns the expected 5.4.36 laravel version…
Thoughts on how I can fix this? Is it possible to downgrade php versions and specify 7.0?
Here is my Homestead.yaml file…
ip: 192.168.10.10
memory: 2048
cpus: 2
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
version: 5.2.0
keys:
- ~/.ssh/id_rsa
folders:
-
map: 'C:UsersRickDesktopMyWebsite'
to: /home/vagrant/code
sites:
-
map: mywebsite.test
to: /home/vagrant/code/public
-
map: sub.mywebsite.test
to: /home/vagrant/code/public
databases:
- homestead
- mywebsite
features:
-
mariadb: false
-
ohmyzsh: false
-
webdriver: false
name: mywebsite
hostname: www.mywebsite.test
2
Answers
Homestead has several versions of PHP. If you view
~/.bash_aliases
, you should see several lines like this:Type
php70
on the command line, and it will switch the command-line versions.For the web versions, you’ll need to either update the nginx config file manually or add the PHP version to the mapping:
You’ll have to destroy the box and restart it to get it to reload the Homestead file.
Using the latest Homestead, you may do the following:
In your
Homestead.yaml
, you may specify a PHP version to each site.If that doesn’t work, you may also change the default version of PHP used by the CLI by issuing any of the following commands from within your Homestead virtual machine:
Eg. Type
php71
in your command line to change the Homestead PHP version to PHP 7.1This will change your Homestead environment according to the PHP version you specify.
You may refer to the Official Documentation for more information.