Search code examples
phplaravellaravel-valet

Laravel Valet 502 Bad Gate Way nginx/1.15.7


I am getting a 502 Bad Gateway on my Laravel projects running Laravel valet.

I have tried many of the solutions online and with no success. i.e. https://gist.github.com/adamwathan/6ea40e90a804ea2b3f9f24146d86ad7f

At the moment the error I see is 502 bad gateway and an error in my command line when running valet install is an error when it gets to the updating PHP configuration. It gives the following error:

Warning: file_get_contents(/usr/local/etc/php/7.3/php-fpm.d/www.conf): failed to open stream: No such file or directory in /Users/username/.composer/vendor/laravel/valet/cli/Valet/Filesystem.php on line 112

Warning: file_get_contents(/usr/local/etc/php/7.3/php-fpm.d/www.conf): failed to open stream: No such file or directory in /Users/username/.composer/vendor/laravel/valet/cli/Valet/Filesystem.php on line 125

Has anybody had similar issues?

Thanks


Solution

  • Had the same symptoms after updating to php 7.3 and then installing a new Laravel project.

    It appears that brew install php73 doesn't install php-fpm

    Solution is to uninstall php

    brew uninstall php73 
    brew uninstall php72
    brew uninstall php71 ... whatever versions you have
    brew uninstall --force php
    

    Now reinstall php

    brew install php --build-from-source
    

    I encountered permission errors mkdir: /usr/local/etc/php/7.3/php-fpm.d: Permission denied so sudo chown -R: <yourusercode> /usr/local/etc/php fixed that and then brew install php --build-from-source again. Once it builds php 7.3 successfully reinstall valet:

    valet install