I had a similar problem when I tried to upgrade Homestead to the latest version of Homestead 7.0 and set it to run PHP 5.6 instead of PH7, which, according to various sources, is possible by adding a line to the .yaml file indicating the version of PHP.
sites: - map: myproject.local to: /home/vagrant/Code/craven/public_html php: "5.6"
In fact, when I tried to do this, I received a 502 CGI gateway error. Here is a summary of the steps I had to take to fix this:
1) SSH to the Homestead virtual machine.
ssh vagrant@127.0.0.1 -p 2222
Looking at the nginx error log in / var / log / nginx /, you will find that the PHP 5.6 files that the server is looking for do not exist.
You can get confirmation of this by looking at the executable files.
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 php 5.6 service is running with the command
service --status-all
3) Once it all works, refresh the web page for your site, and now it should work. In my case, since I was working on a Laravel 4.2 site, I then installed Mcrypt:
sudo apt-get install php5.6-mcrypt
4) In order for my mysql database to be up and running, I also had to install mysql.
sudo apt-get install php5.6-mysql
And, of course, after all this, I had to re-import the contents of the database from the file that I exported before updating the Homestead box.
Please note that if you ever destroy and recreate the Homestead box, you will need to repeat all these steps again.