Homestead Installed PHP7 but I need PHP5

I've been through this issue too and I solved it by installing an old homestead box v0.3.3 and I've used an old release of homestead installer, so I suggest that you remove your current box v0.4.0 and delete your homestead folder then do this:

$vagrant box add laravel/homestead --box-version 0.3.3

and then download an older version of Homestead installer from git, I'm using v2.1.8 it works fine. Enjoy php 5.6 :)


I had a similar problem where I tried to upgrade Homestead to the most recent Homestead 7.0 box and configure it to run PHP 5.6 instead of PH7, which various sources said was possible via adding a line to the .yaml file specifying the PHP version.

sites:
- map: myproject.local
  to: /home/vagrant/Code/craven/public_html
  php: "5.6"

What actually happened when I tried that was that I got a 502 CGI gateway error. Here is a summary of the steps I had to take to fix it:

1) SSH into the Homestead virtual machine.

ssh [email protected] -p 2222

Taking a look at the nginx error log in /var/log/nginx/ reveals that the PHP 5.6 files the server is looking for don't exist.

You can get confirmation of this by having a look at the executables.

ls -la /usr/bin/php*

2) To install PHP 5.6, run

sudo apt-get update
sudo apt-get install php5.6-fpm

You can confirm that the php 5.6 service is running via the command

service --status-all

3) Once all this is working, refresh the web page for your site and it should now work. In my case, because I was running a Laravel 4.2 site, I then to install Mcrypt:

sudo apt-get install php5.6-mcrypt

4) In order to get my mysql database up and running, I also had to install mysql.

sudo apt-get install php5.6-mysql

And of course after all that, I had to re-import the database contents from the file I'd exported before upgrading the Homestead box.

Note that if you ever destroy and recreate the Homestead box, you will need to repeat all these steps again.