Closed dkrasov closed 6 years ago
Sounds like PHP isn't started properly, as nginx can't find phpfpm on the valet.sock
socket.
Or else the edit to the default php configuration didn't work properly: https://github.com/laravel/valet/blob/master/cli/Valet/PhpFpm.php#L63
@dmitriymarley I'm closing this as you haven't responded--but if you find that @drbyte's response hasn't helped, please feel free to re-open.
Hello guys,
I was having the same issue after knocking my head around i came upto this solution and its working perfectly .. Here you go 👍
so Firstly, i install Brew : /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Then i installed php71 which is now php@7.1 : brew install php71
-> after installation export : echo 'export PATH="/usr/local/opt/php@7.1/bin:$PATH"' >> ~/.bash_profile echo 'export PATH="/usr/local/opt/php@7.1/sbin:$PATH"' >> ~/.bash_profile
-> brew link php@7.1 --force --overwrite
->ln -s $(which php) /usr/local/bin/php
Then i installed composer using :
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" php composer-setup.php php -r "unlink('composer-setup.php');"
and mv composer.phar /usr/local/bin/composer
and then installed valet : composer global require laravel/valet
And then comes the tricky part :
-> open -e /Users/USERNAME-Directory/.composer/vendor/laravel/valet/cli/Valet/Brew.php
and alter
function supportedPhpVersions() { return collect(['php', 'php72', 'php71', 'php70', 'php56','php@7.1']); }
-> open -e /Users/USERNAME-Directory/.composer/vendor/laravel/valet/cli/Valet/PhpFpm.php
and alter
function fpmConfigPath() { $confLookup = [ 'php' => '/usr/local/etc/php/7.2/php-fpm.d/www.conf', 'php72' => '/usr/local/etc/php/7.2/php-fpm.d/www.conf', 'php71' => '/usr/local/etc/php/7.1/php-fpm.d/www.conf', 'php70' => '/usr/local/etc/php/7.0/php-fpm.d/www.conf', 'php56' => '/usr/local/etc/php/5.6/php-fpm.conf', 'php@7.1' => '/usr/local/etc/php/7.1/php-fpm.d/www.conf' ];
return $confLookup[$this->brew->linkedPhp()];
} and then final step : sudo brew services restart nginx && sudo brew services restart php@7.1
And DONE!!!!
Cheers!!
Wow, that actually worked for me as well!
One thing i had to do afterwards though:
valet install
Thanks!
Just valet install
did it for me. Also kept my previous config as it was, which is awesome.
Writing this here incase it helps anyone in 2021 - I had to copy /usr/local/etc/php/8.0/php-fpm.d/valet-fpm.conf
to /usr/local/etc/php/8.0/php-fpm.conf
. This solved my issue of the 502 error. Looking at the php-fpm logs revealed that the conf file wasn't being loaded - because it didn't exist. I'm guessing there's a reason for this, but working with only valet, it was easier to clone the file and rename it, than to spend my life figuring out why the server gods reject me so
@yratof Thank you. I found your answer working for me. Thanks for sharing
thanks a bunch @yratof after spending a lifetime (2 days) on this, your suggestion helped.
@yratof Thank you! you're a life saver
@yratof Thanks you. u saved me
In addition to the solution of @yratof which solved it for us, but in a different way because of a fresh install on an M1 machine. This reply is the equivalent for it
Just in case the reply in the link is removed:
cd /opt/homebrew/etc/php/8.1 && sudo cp php-fpm.d/valet-fpm.conf php-fpm.conf
cd /opt/homebrew/etc/php/8.1 sudo cp php-fpm.d/valet-fpm.conf php-fpm.conf
@coreation Thank you so much, had this issue for 2 days now! <3
cd /opt/homebrew/etc/php/8.1 sudo cp php-fpm.d/valet-fpm.conf php-fpm.conf
@coreation Thank you so much, had this issue for 2 days now! <3
Ah, great to hear it served at least 1 person @Groganj89 ! These kind of things are very tedious to fix ;) Have a good one!
cd /opt/homebrew/etc/php/8.1 sudo cp php-fpm.d/valet-fpm.conf php-fpm.conf
@coreation Thank you so much, had this issue for 2 days now! <3
Ah, great to hear it served at least 1 person @Groganj89 ! These kind of things are very tedious to fix ;) Have a good one!
You too bud! thank you again :)
In addition to the solution of @yratof which solved it for us, but in a different way because of a fresh install on an M1 machine. This reply is the equivalent for it
Just in case the reply in the link is removed:
cd /opt/homebrew/etc/php/8.1 && sudo cp php-fpm.d/valet-fpm.conf php-fpm.conf
thank you bro, you just saved me a week of uninstalling and installing php on my m1 mac
In addition to the solution of @yratof which solved it for us, but in a different way because of a fresh install on an M1 machine. This reply is the equivalent for it Just in case the reply in the link is removed:
cd /opt/homebrew/etc/php/8.1 && sudo cp php-fpm.d/valet-fpm.conf php-fpm.conf
thank you bro, you just saved me a week of uninstalling and installing php on my m1 mac
You're very welcome, have a good one!
brew update
composer global require laravel/valet
valet install
these worked for me
In addition to the solution of @yratof which solved it for us, but in a different way because of a fresh install on an M1 machine. This reply is the equivalent for it
Just in case the reply in the link is removed:
cd /opt/homebrew/etc/php/8.1 && sudo cp php-fpm.d/valet-fpm.conf php-fpm.conf
I did this but with php 8.2 and it still works!!! Thanks for this
Writing this here incase it helps anyone in 2021 - I had to copy
/usr/local/etc/php/8.0/php-fpm.d/valet-fpm.conf
to/usr/local/etc/php/8.0/php-fpm.conf
. This solved my issue of the 502 error. Looking at the php-fpm logs revealed that the conf file wasn't being loaded - because it didn't exist. I'm guessing there's a reason for this, but working with only valet, it was easier to clone the file and rename it, than to spend my life figuring out why the server gods reject me so
It works for me, i spend 4 hours to figure it out. You made my day
valet install
This worked for me.
Hey guys, I'm on my new Mac OS Sierra (fresh install) and trying to get valet working. It was okay for a while, but after rebooting my Mac nginx started to throw me 502 error. In nginx error log I've found the next lines:
I've tried almost everything:
dev-master
too).valet
folderWhat am I doing wrong?