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

s3w47m88's avatar

Homestead using a different version of PHP than I've commanded it to?

Here's a video explaining this in detail: https://www.loom.com/share/4c6765c1de194f3cb23fae3cea0e17cb

I have an older Laravel site (5.8) that I need to upgrade to 8.0. I may be using Shift to do this but I have never done an upgrade manually so I thought I should do that at least once.

So I upgraded Homestead to current (12.x), and everything continued to run fine.

Then I tried to upgrade my PHP version from 7.1 to 8.0 and, as expected, I began getting deprecation errors in browser.

So I switched back to 7.1 but the errors remained! I try php -v and it reports I'm back to 7.1, I even specified in my Homestead.yaml file under Sites to specific PHP version 7.1.

I've also tried re-provisioning, reloading with provision command, and destroying and rebuilding. All with the same end result of outstanding deprecation errors that I believe are only items deprecated in PHP8.

Am I missing a step?

I am on Windows 10.

I've tried the Answers in this StackOverflows https://stackoverflow.com/questions/47849825/change-laravel-homestead-v7-0-1-with-php-7-2-to-php-7-1 including php71.

0 likes
11 replies
s3w47m88's avatar

Thanks, I've done that but it gives me a 502 Bad Gateway message now. I've reverted for the time being. But I didn't need that originally so it seems like I shouldn't need it now.

After I got the 502 error I checked my NGinx sites-enabled on the server to ensure it was there and correct and it was. I also checked my Windows hosts file and the site and IP remain unchanged. I don't know what else would prevent the server from finding the site in that case?

maclervil's avatar

Start or restart your php service on your server. If your php version is 7.4, you can do run for example : sudo service php7.4-fpm restart

s3w47m88's avatar

I've added php: "7.1" to the Homestead.yml file, destroyed the virtual box and recreated it, then ssh'd in and executed sudo service php7.1-fpm restart but I'm getting the error page still.

https://prnt.sc/1qcs0jt

s3w47m88's avatar

I tried one more time and it still is setting 8.0.x instead of 7.1

maclervil's avatar

what command you execute to know your php version?

s3w47m88's avatar

To further clarify phpinfo outputs the application is using 8.x even though php -v says 7.1

1 like
maclervil's avatar

Ok. What php version you have in your composer.json?

s3w47m88's avatar

I finally resolved the issue.

There is PHP-CLI and PHP-web. PHP-CLI version is what is reported when using php -v but PHP-CLI is what NGinx is using, hence getting 8.0 when using phpinfo() in ~/public/index.php

To resolve the issue I manually updated /etc/nginx/sites-enabled/mysite and edited line below location where it says fastcgi_pass unix:/var/run/php/php8.0-fpm.sock; to say fastcgi_pass unix:/var/run/php/php7.1-fpm.sock; and then I restarted PHP with sudo systemctl restart nginx.

2 likes

Please or to participate in this conversation.