laravel / valet

A more enjoyable local development experience for Mac.
https://laravel.com/docs/valet
MIT License
2.5k stars 693 forks source link

Nginx 502 Bad Gateway #1052

Closed Mohammed-Alama closed 3 years ago

Mohammed-Alama commented 3 years ago

Hi I have try to update php to 8.0 but always there a problem with valet to read the new version and I try to solve it without specific instructions but this time is stucked

Expected behavior

I expect valet to work again and serve my projects

Current behavior

I have tried this command from #920 ➜ ~ sudo /usr/local/opt/php/sbin/php-fpm --test [04-Apr-2021 10:54:58] ERROR: failed to open configuration file '/usr/local/etc/php/8.0/php-fpm.conf': No such file or directory (2) [04-Apr-2021 10:54:58] ERROR: failed to load configuration file '/usr/local/etc/php/8.0/php-fpm.conf' [04-Apr-2021 10:54:58] ERROR: FPM initialization failed

➜ ~ php --ini Configuration File (php.ini) Path: /usr/local/etc/php/8.0 Loaded Configuration File: (none) Scan for additional .ini files in: /usr/local/etc/php/8.0/conf.d Additional .ini files parsed: /usr/local/etc/php/8.0/conf.d/error_log.ini, /usr/local/etc/php/8.0/conf.d/php-memory-limits.ini

➜ ~ brew services list Name Status User Plist dnsmasq unknown root /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist httpd stopped mysql started mohammedalama /usr/local/opt/mysql/homebrew.mxcl.mysql.plist nginx unknown root /Library/LaunchDaemons/homebrew.mxcl.nginx.plist php error root /Library/LaunchDaemons/homebrew.mxcl.php.plist redis started mohammedalama /usr/local/opt/redis/homebrew.mxcl.redis.plist supervisor started mohammedalama /usr/local/opt/supervisor/homebrew.mxcl.supervisor.plist

Output of these steps

Possible solution

Diagnosis

sw_vers
ProductName:   macOS
ProductVersion: 11.1
BuildVersion:   20C69
valet --version
Laravel Valet 2.14.1
cat ~/.config/valet/config.json
{
    "tld": "test",
    "paths": [
        "/Users/mohammedalama/.config/valet/Sites",
        "/Users/mohammedalama/Documents/Work",
        "/Users/mohammedalama/Documents/Code",
        "/Users/mohammedalama/Documents/Code/FrontEnd_Projects",
        "/Users/mohammedalama/Documents/Code/BackEnd_Projects",
        "/Users/mohammedalama/Code/php",
        "/Users/mohammedalama/Code/js"
    ],
    "loopback": "127.0.0.1"
}
cat ~/.composer/composer.json
{
    "require": {
        "laravel/installer": "^4.0",
        "psy/psysh": "@stable",
        "tightenco/lambo": "^0.5.5",
        "laravel/envoy": "^1.6",
        "friendsofphp/php-cs-fixer": "^2.16",
        "beyondcode/expose": "^1.2",
        "laravel/valet": "^2.14"
    }
}
composer global diagnose
Changed current directory to /Users/mohammedalama/.composer
Checking composer.json: WARNING
No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.
require.psy/psysh : unbound version constraints (@stable) should be avoided
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com oauth access: OK
Checking disk free space: OK
Checking pubkeys: 
Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0  87719BA6 8F3BB723 4E5D42D0 84A14642
Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B  0C708369 153E328C AD90147D AFE50952
OK
Checking composer version: You are not running the latest snapshot version, run `composer self-update` to update (dca8bd71975910345ed4c3bc11122c11a01f6352 => 91136213d11630d881bf8ff9c0e1df37daf50d22)
Composer version: 2.1-dev+dca8bd71975910345ed4c3bc11122c11a01f6352
PHP version: 8.0.3
PHP binary path: /usr/local/Cellar/php/8.0.3/bin/php
OpenSSL version: OpenSSL 1.1.1j  16 Feb 2021
cURL version: 7.76.0 libz 1.2.11 ssl (SecureTransport) OpenSSL/1.1.1k
zip: extension present, unzip present
composer global outdated
Changed current directory to /Users/mohammedalama/.composer
illuminate/container v6.20.22 ~ v8.35.1 The Illuminate Container package.
illuminate/contracts v6.20.22 ~ v8.35.1 The Illuminate Contracts package.
illuminate/support   v6.20.22 ~ v8.35.1 The Illuminate Support package.
laravel/envoy        v1.6.5   ~ v2.7.0  Elegant SSH tasks for PHP.
php-cs-fixer/diff    v1.3.1   ~ v2.0.2  sebastian/diff v2 backport support for PHP5.6
psr/container        1.1.1    ~ 2.0.1   Common Container Interface (PHP FIG PSR-11)
tightenco/lambo      v0.5.5   ~ v1.0.1  Super-powered 'laravel new' with Laravel and Valet.
ls -al /etc/sudoers.d/
total 16
drwxr-xr-x    4 root  wheel   128 Dec 17 08:04 .
drwxr-xr-x  122 root  wheel  3904 Apr  1 16:13 ..
-rw-r--r--    1 root  wheel    80 Sep 17  2019 brew
-rw-r--r--    1 root  wheel    83 Sep 17  2019 valet
brew config
HOMEBREW_VERSION: 3.0.10
ORIGIN: https://github.com/Homebrew/brew
HEAD: 0ad2564c5f1ddf6f16f707f2861556b80546713c
Last commit: 6 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: bff5e515dadc66aba152ce59cdc1e43348288805
Core tap last commit: 48 seconds ago
Core tap branch: master
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 4
Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: quad-core 64-bit broadwell
Clang: 11.0 build 1103
Git: 2.28.0 => /usr/local/bin/git
Curl: 7.64.1 => /usr/bin/curl
macOS: 11.1-x86_64
CLT: 1103.0.32.59
Xcode: 11.3.1
brew services list
Name       Status  User          Plist
dnsmasq    unknown root          /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
httpd      stopped               
mysql      started mohammedalama /usr/local/opt/mysql/homebrew.mxcl.mysql.plist
nginx      unknown root          /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
php        error   root          /Library/LaunchDaemons/homebrew.mxcl.php.plist
redis      started mohammedalama /usr/local/opt/redis/homebrew.mxcl.redis.plist
supervisor started mohammedalama /usr/local/opt/supervisor/homebrew.mxcl.supervisor.plist
brew list --formula --versions | grep -E "(php|nginx|dnsmasq|mariadb|mysql|mailhog|openssl)(@\d\..*)?\s"
dnsmasq 2.84
mysql 8.0.19
nginx 1.19.8
openssl@1.1 1.1.1k
php 8.0.3
brew outdated
cairo
elixir
erlang
fzf
gcc@6
gh
ghostscript
git
gobject-introspection
graphviz
harfbuzz
heroku/brew/heroku
heroku/brew/heroku-node
httpd
hugo
ilmbase
imagemagick
isl
jasper
libde265
libheif
libmpc
libomp
little-cms2
mas-cli/tap/mas
mycli
mysql
netpbm
openexr
openjpeg
pango
php-cs-fixer
protobuf
python@3.8
redis
shared-mime-info
supervisor
telnet
x265
youtube-dl
zsh
font-hack-nerd-font
brew tap
caskroom/cask
github/gh
heroku/brew
homebrew/cask
homebrew/cask-fonts
homebrew/core
homebrew/services
mas-cli/tap
sambadevi/powerlevel9k
shivammathur/php
php -v
PHP 8.0.3 (cli) (built: Mar  4 2021 20:45:17) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.3, Copyright (c) Zend Technologies
which -a php
/usr/local/opt/php@8.0/bin/php
/usr/bin/php
/usr/local/bin/php
php --ini
Configuration File (php.ini) Path: /usr/local/etc/php/8.0
Loaded Configuration File:         (none)
Scan for additional .ini files in: /usr/local/etc/php/8.0/conf.d
Additional .ini files parsed:      /usr/local/etc/php/8.0/conf.d/error_log.ini,
/usr/local/etc/php/8.0/conf.d/php-memory-limits.ini
nginx -v
nginx version: nginx/1.19.8
curl --version
curl 7.64.1 (x86_64-apple-darwin20.0) libcurl/7.64.1 (SecureTransport) LibreSSL/2.8.3 zlib/1.2.11 nghttp2/1.41.0
Release-Date: 2019-03-27
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS GSS-API HTTP2 HTTPS-proxy IPv6 Kerberos Largefile libz MultiSSL NTLM NTLM_WB SPNEGO SSL UnixSockets
php --ri curl
curl

cURL support => enabled
cURL Information => 7.76.0
Age => 8
Features
AsynchDNS => Yes
CharConv => No
Debug => No
GSS-Negotiate => No
IDN => Yes
IPv6 => Yes
krb4 => No
Largefile => Yes
libz => Yes
NTLM => Yes
NTLMWB => Yes
SPNEGO => Yes
SSL => Yes
SSPI => No
TLS-SRP => Yes
HTTP2 => Yes
GSSAPI => Yes
KERBEROS5 => Yes
UNIX_SOCKETS => Yes
PSL => No
HTTPS_PROXY => Yes
MULTI_SSL => Yes
BROTLI => Yes
Protocols => dict, file, ftp, ftps, gopher, gophers, http, https, imap, imaps, ldap, ldaps, mqtt, pop3, pop3s, rtmp, rtsp, scp, sftp, smb, smbs, smtp, smtps, telnet, tftp
Host => x86_64-apple-darwin20.3.0
SSL Version => (SecureTransport) OpenSSL/1.1.1k
ZLib Version => 1.2.11
libSSH Version => libssh2/1.9.0

Directive => Local Value => Master Value
curl.cainfo => no value => no value
~/.composer/vendor/laravel/valet/bin/ngrok version
ngrok version 2.3.35
ls -al ~/.ngrok2
total 8
drwx------    3 mohammedalama  staff    96 Jun 14  2019 .
drwxr-xr-x+ 128 mohammedalama  staff  4096 Apr  4 11:08 ..
-rw-------@   1 mohammedalama  staff    55 Jun 14  2019 ngrok.yml
brew info nginx
nginx: stable 1.19.8 (bottled), HEAD
HTTP(S) server and reverse proxy, and IMAP/POP3 proxy server
https://nginx.org/
/usr/local/Cellar/nginx/1.19.8 (25 files, 2.2MB) *
  Poured from bottle on 2021-04-01 at 17:16:40
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/nginx.rb
License: BSD-2-Clause
==> Dependencies
Required: openssl@1.1, pcre
==> Options
--HEAD
    Install HEAD version
==> Caveats
Docroot is: /usr/local/var/www

The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.

nginx will load all files in /usr/local/etc/nginx/servers/.

To have launchd start nginx now and restart at login:
  brew services start nginx
Or, if you don't want/need a background service you can just run:
  nginx
==> Analytics
install: 46,886 (30 days), 129,723 (90 days), 477,076 (365 days)
install-on-request: 46,775 (30 days), 129,442 (90 days), 470,164 (365 days)
build-error: 0 (30 days)
brew info php
php: stable 8.0.3 (bottled), HEAD
General-purpose scripting language
https://www.php.net/
/usr/local/Cellar/php/8.0.3 (499 files, 77.8MB) *
  Poured from bottle on 2021-04-01 at 17:18:15
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/php.rb
License: PHP-3.01
==> Dependencies
Build: httpd, pkg-config
Required: apr, apr-util, argon2, aspell, autoconf, curl, freetds, gd, gettext, glib, gmp, icu4c, krb5, libffi, libpq, libsodium, libzip, oniguruma, openldap, openssl@1.1, pcre2, sqlite, tidy-html5, unixodbc
==> Options
--HEAD
    Install HEAD version
==> Caveats
To enable PHP in Apache add the following to httpd.conf and restart Apache:
    LoadModule php_module /usr/local/opt/php/lib/httpd/modules/libphp.so

    
        SetHandler application/x-httpd-php
    

Finally, check DirectoryIndex includes index.php
    DirectoryIndex index.php index.html

The php.ini and php-fpm.ini file can be found in:
    /usr/local/etc/php/8.0/

To have launchd start php now and restart at login:
  brew services start php
Or, if you don't want/need a background service you can just run:
  php-fpm
==> Analytics
install: 47,253 (30 days), 155,891 (90 days), 633,677 (365 days)
install-on-request: 46,447 (30 days), 152,972 (90 days), 615,396 (365 days)
build-error: 0 (30 days)
brew info openssl
openssl@1.1: stable 1.1.1k (bottled) [keg-only]
Cryptography and SSL/TLS Toolkit
https://openssl.org/
/usr/local/Cellar/openssl@1.1/1.1.1k (8,071 files, 18.5MB)
  Poured from bottle on 2021-03-31 at 15:14:11
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/openssl@1.1.rb
License: OpenSSL
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/openssl@1.1/certs

and run
  /usr/local/opt/openssl@1.1/bin/c_rehash

openssl@1.1 is keg-only, which means it was not symlinked into /usr/local,
because macOS provides LibreSSL.

If you need to have openssl@1.1 first in your PATH, run:
  echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> ~/.zshrc

For compilers to find openssl@1.1 you may need to set:
  export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
  export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"

For pkg-config to find openssl@1.1 you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig"

==> Analytics
install: 889,489 (30 days), 2,483,892 (90 days), 8,975,727 (365 days)
install-on-request: 75,304 (30 days), 322,680 (90 days), 1,260,940 (365 days)
build-error: 0 (30 days)
openssl version -a
OpenSSL 1.1.1k  25 Mar 2021
built on: Thu Mar 25 21:01:05 2021 UTC
platform: darwin64-x86_64-cc
options:  bn(64,64) rc4(16x,int) des(int) idea(int) blowfish(ptr) 
compiler: clang -fPIC -arch x86_64 -O3 -Wall -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAESNI_ASM -DVPAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPOLY1305_ASM -D_REENTRANT -DNDEBUG
OPENSSLDIR: "/usr/local/etc/openssl@1.1"
ENGINESDIR: "/usr/local/Cellar/openssl@1.1/1.1.1k/lib/engines-1.1"
Seeding source: os-specific
openssl ciphers
TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA:RSA-PSK-AES256-GCM-SHA384:DHE-PSK-AES256-GCM-SHA384:RSA-PSK-CHACHA20-POLY1305:DHE-PSK-CHACHA20-POLY1305:ECDHE-PSK-CHACHA20-POLY1305:AES256-GCM-SHA384:PSK-AES256-GCM-SHA384:PSK-CHACHA20-POLY1305:RSA-PSK-AES128-GCM-SHA256:DHE-PSK-AES128-GCM-SHA256:AES128-GCM-SHA256:PSK-AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:ECDHE-PSK-AES256-CBC-SHA384:ECDHE-PSK-AES256-CBC-SHA:SRP-RSA-AES-256-CBC-SHA:SRP-AES-256-CBC-SHA:RSA-PSK-AES256-CBC-SHA384:DHE-PSK-AES256-CBC-SHA384:RSA-PSK-AES256-CBC-SHA:DHE-PSK-AES256-CBC-SHA:AES256-SHA:PSK-AES256-CBC-SHA384:PSK-AES256-CBC-SHA:ECDHE-PSK-AES128-CBC-SHA256:ECDHE-PSK-AES128-CBC-SHA:SRP-RSA-AES-128-CBC-SHA:SRP-AES-128-CBC-SHA:RSA-PSK-AES128-CBC-SHA256:DHE-PSK-AES128-CBC-SHA256:RSA-PSK-AES128-CBC-SHA:DHE-PSK-AES128-CBC-SHA:AES128-SHA:PSK-AES128-CBC-SHA256:PSK-AES128-CBC-SHA
sudo nginx -t
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
which -a php-fpm
/usr/sbin/php-fpm
/usr/local/opt/php/sbin/php-fpm -v
PHP 8.0.3 (fpm-fcgi) (built: Mar  4 2021 20:45:30)
Copyright (c) The PHP Group
Zend Engine v4.0.3, Copyright (c) Zend Technologies
sudo /usr/local/opt/php/sbin/php-fpm -y /usr/local/etc/php/8.0/php-fpm.conf --test
[04-Apr-2021 11:09:20] ERROR: failed to open configuration file '/usr/local/etc/php/8.0/php-fpm.conf': No such file or directory (2)
[04-Apr-2021 11:09:20] ERROR: failed to load configuration file '/usr/local/etc/php/8.0/php-fpm.conf'
[04-Apr-2021 11:09:20] ERROR: FPM initialization failed
ls -al ~/Library/LaunchAgents | grep homebrew

ls -al /Library/LaunchAgents | grep homebrew

ls -al /Library/LaunchDaemons | grep homebrew
-rw-r--r--   1 root  admin   657 Apr  4 11:03 homebrew.mxcl.dnsmasq.plist
-rw-r--r--   1 root  admin   571 Apr  4 11:03 homebrew.mxcl.nginx.plist
-rw-r--r--   1 root  admin   628 Apr  4 11:03 homebrew.mxcl.php.plist
ls -al /Library/LaunchDaemons | grep "com.laravel.valet."

ls -aln /etc/resolv.conf
lrwxr-xr-x  1 0  0  22 Jan  1  2020 /etc/resolv.conf -> ../var/run/resolv.conf
cat /etc/resolv.conf
#
# macOS Notice
#
# This file is not consulted for DNS hostname resolution, address
# resolution, or the DNS query routing mechanism used by most
# processes on this system.
#
# To view the DNS configuration used by this system, use:
#   scutil --dns
#
# SEE ALSO
#   dns-sd(1), scutil(8)
#
# This file is automatically generated.
#
search 8.8.4.4 8.8.8.8
nameserver 8.8.8.8
ifconfig lo0
lo0: flags=8049 mtu 16384
    options=1203
    inet 127.0.0.1 netmask 0xff000000 
    inet6 ::1 prefixlen 128 
    inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 
    nd6 options=201
sh -c 'echo "------\n/usr/local/etc/nginx/valet/valet.conf\n---\n"; cat /usr/local/etc/nginx/valet/valet.conf | grep -n "# valet loopback"; echo "\n------\n"'
------
/usr/local/etc/nginx/valet/valet.conf
---

3:    #listen VALET_LOOPBACK:80; # valet loopback

------
sh -c 'for file in ~/.config/valet/dnsmasq.d/*; do echo "------\n~/.config/valet/dnsmasq.d/$(basename $file)\n---\n"; cat $file; echo "\n------\n"; done'
------
~/.config/valet/dnsmasq.d/tld-com.conf
---

address=/.com/127.0.0.1
listen-address=127.0.0.1

------

------
~/.config/valet/dnsmasq.d/tld-test.conf
---

address=/.test/127.0.0.1
listen-address=127.0.0.1

------
sh -c 'for file in ~/.config/valet/nginx/*; do echo "------\n~/.config/valet/nginx/$(basename $file)\n---\n"; cat $file | grep -n "# valet loopback"; echo "\n------\n"; done'
------
~/.config/valet/nginx/altahalufgrouptest.test
---

3:    #listen 127.0.0.1:80; # valet loopback
10:    #listen 127.0.0.1:443 ssl http2; # valet loopback
54:    #listen 127.0.0.1:60; # valet loopback

------

------
~/.config/valet/nginx/blog.test
---

3:    #listen 127.0.0.1:80; # valet loopback
10:    #listen 127.0.0.1:443 ssl http2; # valet loopback
54:    #listen 127.0.0.1:60; # valet loopback

------

------
~/.config/valet/nginx/dev.test
---

3:    #listen 127.0.0.1:80; # valet loopback
10:    #listen 127.0.0.1:443 ssl http2; # valet loopback
54:    #listen 127.0.0.1:60; # valet loopback

------

------
~/.config/valet/nginx/tailors_doctors.test
---

3:    #listen 127.0.0.1:80; # valet loopback
10:    #listen 127.0.0.1:443 ssl http2; # valet loopback
54:    #listen 127.0.0.1:60; # valet loopback

------

------
~/.config/valet/nginx/test--chatbot.test
---

3:    #listen 127.0.0.1:80; # valet loopback
10:    #listen 127.0.0.1:443 ssl http2; # valet loopback
54:    #listen 127.0.0.1:60; # valet loopback

------

------
~/.config/valet/nginx/travel_planet.test
---

3:    #listen 127.0.0.1:80; # valet loopback
10:    #listen 127.0.0.1:443 ssl http2; # valet loopback
54:    #listen 127.0.0.1:60; # valet loopback

------

------
~/.config/valet/nginx/volcano.test
---

3:    #listen 127.0.0.1:80; # valet loopback
10:    #listen 127.0.0.1:443 ssl http2; # valet loopback
54:    #listen 127.0.0.1:60; # valet loopback

------

------
~/.config/valet/nginx/wp-test.test
---

3:    #listen 127.0.0.1:80; # valet loopback
10:    #listen 127.0.0.1:443 ssl http2; # valet loopback
54:    #listen 127.0.0.1:60; # valet loopback

------
drbyte commented 3 years ago

ERROR: failed to open configuration file '/usr/local/etc/php/8.0/php-fpm.conf': No such file or directory

A fresh install of PHP normally creates that file. And if that file already exists then it also creates a corresponding php-fpm.conf.default file as the file would exist before any customizations if you'd made any.

Valet doesn't touch that file at all (er, well back in PHP 5.6 it had to, but this isn't that).

It would seem that something in your environment is deleting or preventing the installation of /usr/local/etc/php/8.0/php-fpm.conf.

quintenbuis commented 3 years ago

Having the same issue here

drbyte commented 3 years ago

Having the same issue here

Which "same issue"? Which symptoms? What was your computer state before encountering this? fresh install of os? or old valet version? or upgrading from older PHP version? which version? what steps did you take to encounter this situation?

As you can see, there's a LOT of information missing from your post, making it impossible to provide any assistance.

quintenbuis commented 3 years ago

@drbyte Got it working for php@8.0 by doing brew uninstall php@8.0. then running valet use php@8.0 --force. It tried to install it again but failed. So I ran brew uninstall php@8.0 again and it prompted to run the following command: sudo rm -rf /usr/local/etc/php I also ran sudo rm -rf /usr/local/Cellar/php and sudo rm -rf /usr/local/Cellar/php* to remove all php traces. Then did valet use php@8.0 --force again and it worked. But when I then tried to run valet use php@7.4 it gave a 502 error.

quintenbuis commented 3 years ago

Ok got it working!

Here is my command history. Remove all php traces and the walk through the install guide https://laravel.com/docs/8.x/valet#installation

Maybe this happened because I skipped the brew install php Or my php stuff was stained by https://github.com/weprovide/valet-plus

10319  sudo rm -rf /usr/local/Cellar/php
10320  sudo rm -rf /usr/local/Cellar/php*
10321  valet use php@7.4
10322  brew uninstall php@7.4
10325  sudo rm -rf /usr/local/etc/php
10326  brew uninstall php@7.4
10327  brew install php
10332  composer global update laravel/valet
10333  valet install
10334  valet use php@8.0
10335  valet use php@7.4
10336  valet use php@8.0
drbyte commented 3 years ago

Or my php stuff was stained by https://github.com/weprovide/valet-plus

Ya, if you've got that other project's stuff in your system you'll definitely have issues.

drbyte commented 3 years ago

You didn't post output of valet diagnose so it's unknown whether you have other issues due to outdated composer and brew software. Running composer global update and brew upgrade weekly is advisable. So is composer self-update

DaudiMuriu commented 3 years ago

Hey, i am also experiencing the same issue with valet where I get the same error. I am using php@7.4. I have tried a lot of things which include but not limited to removing all other PHP versions, removing valet, nginx, dnsmasq plus those listed above but nothing seems to work. I can ping any .test domain but whenever I try accessing my projects either from postman or the browser, I get a 502.

Any help would be greatly appreciated 😭

When I run valet logs for Nginx I am getting this 2021/04/06 23:58:21 [crit] 17331#0: *1 connect() to unix:/Users/daudi/.config/valet/valet.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/Users/daudi/.config/valet/valet.sock:", host: "laravel-satchel-client-api.test"

here is the output of valet diagnose `

sw_vers
ProductName:   macOS
ProductVersion: 11.2.3
BuildVersion:   20D91

valet --version
Laravel Valet 2.14.1
cat ~/.config/valet/config.json
{
    "tld": "test",
    "loopback": "127.0.0.1",
    "paths": []
}
cat ~/.composer/composer.json
{
    "require": {
        "laravel/installer": "^4.2",
        "laravel/valet": "^2.14"
    }
}
composer global diagnose
Changed current directory to /Users/daudi/.composer
Checking composer.json: WARNING
No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking pubkeys: 
OK
Checking composer version: OK
Composer version: 2.0.12
PHP version: 7.4.16
PHP binary path: /usr/local/Cellar/php@7.4/7.4.16/bin/php
OpenSSL version: OpenSSL 1.1.1j  16 Feb 2021
cURL version: 7.76.0 libz 1.2.11 ssl (SecureTransport) OpenSSL/1.1.1k
zip: extension present, unzip present
composer global outdated
Changed current directory to /Users/daudi/.composer
psr/container 1.1.1 ~ 2.0.1 Common Container Interface (PHP FIG PSR-11)
ls -al /etc/sudoers.d/
total 0
drwxr-xr-x   2 root  wheel    64 Jan  1  2020 .
drwxr-xr-x  86 root  wheel  2752 Apr  6 23:25 ..
brew config
HOMEBREW_VERSION: 3.0.11
ORIGIN: https://github.com/Homebrew/brew
HEAD: 8e11f03fa93b148e26044a331654241a2c307039
Last commit: 33 hours ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: fc9241688bdaf9103bc081909e17c3916e97f293
Core tap last commit: 2 minutes ago
Core tap branch: master
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 8
Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: octa-core 64-bit icelake
Clang: 12.0 build 1200
Git: 2.31.1 => /usr/local/bin/git
Curl: 7.64.1 => /usr/bin/curl
macOS: 11.2.3-x86_64
CLT: 12.4.0.0.1.1610135815
Xcode: N/A
brew services list
Name    Status  User  Plist
dnsmasq error   root  /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
mariadb started daudi /Users/daudi/Library/LaunchAgents/homebrew.mxcl.mariadb.plist
nginx   error   root  /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
php     error   root  /Library/LaunchDaemons/homebrew.mxcl.php.plist
php@7.4 error   root  /Library/LaunchDaemons/homebrew.mxcl.php@7.4.plist
redis   started daudi /Users/daudi/Library/LaunchAgents/homebrew.mxcl.redis.plist
brew list --formula --versions | grep -E "(php|nginx|dnsmasq|mariadb|mysql|mailhog|openssl)(@\d\..*)?\s"
dnsmasq 2.84
mariadb 10.5.9
nginx 1.19.8
openssl@1.1 1.1.1k
php 8.0.3
php@7.4 7.4.16
brew outdated

brew tap
homebrew/core
homebrew/services
shivammathur/php
php -v
PHP 7.4.16 (cli) (built: Mar  4 2021 20:52:51) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
which -a php
/usr/local/bin/php
/usr/bin/php
php --ini
Configuration File (php.ini) Path: /usr/local/etc/php/7.4
Loaded Configuration File:         (none)
Scan for additional .ini files in: /usr/local/etc/php/7.4/conf.d
Additional .ini files parsed:      /usr/local/etc/php/7.4/conf.d/error_log.ini,
/usr/local/etc/php/7.4/conf.d/php-memory-limits.ini
nginx -v
nginx version: nginx/1.19.8
curl --version
curl 7.64.1 (x86_64-apple-darwin20.0) libcurl/7.64.1 (SecureTransport) LibreSSL/2.8.3 zlib/1.2.11 nghttp2/1.41.0
Release-Date: 2019-03-27
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS GSS-API HTTP2 HTTPS-proxy IPv6 Kerberos Largefile libz MultiSSL NTLM NTLM_WB SPNEGO SSL UnixSockets
php --ri curl
curl

cURL support => enabled
cURL Information => 7.76.0
Age => 8
Features
AsynchDNS => Yes
CharConv => No
Debug => No
GSS-Negotiate => No
IDN => Yes
IPv6 => Yes
krb4 => No
Largefile => Yes
libz => Yes
NTLM => Yes
NTLMWB => Yes
SPNEGO => Yes
SSL => Yes
SSPI => No
TLS-SRP => Yes
HTTP2 => Yes
GSSAPI => Yes
KERBEROS5 => Yes
UNIX_SOCKETS => Yes
PSL => No
HTTPS_PROXY => Yes
MULTI_SSL => Yes
BROTLI => Yes
Protocols => dict, file, ftp, ftps, gopher, gophers, http, https, imap, imaps, ldap, ldaps, mqtt, pop3, pop3s, rtmp, rtsp, scp, sftp, smb, smbs, smtp, smtps, telnet, tftp
Host => x86_64-apple-darwin20.3.0
SSL Version => (SecureTransport) OpenSSL/1.1.1k
ZLib Version => 1.2.11
libSSH Version => libssh2/1.9.0

Directive => Local Value => Master Value
curl.cainfo => no value => no value
~/.composer/vendor/laravel/valet/bin/ngrok version
ngrok version 2.3.35
ls -al ~/.ngrok2
ls: /Users/daudi/.ngrok2: No such file or directory
brew info nginx
nginx: stable 1.19.8 (bottled), HEAD
HTTP(S) server and reverse proxy, and IMAP/POP3 proxy server
https://nginx.org/
/usr/local/Cellar/nginx/1.19.8 (25 files, 2.2MB) *
  Poured from bottle on 2021-04-06 at 23:38:57
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/nginx.rb
License: BSD-2-Clause
==> Dependencies
Required: openssl@1.1, pcre
==> Options
--HEAD
    Install HEAD version
==> Caveats
Docroot is: /usr/local/var/www

The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.

nginx will load all files in /usr/local/etc/nginx/servers/.

To have launchd start nginx now and restart at login:
  brew services start nginx
Or, if you don't want/need a background service you can just run:
  nginx
==> Analytics
install: 46,309 (30 days), 127,444 (90 days), 477,421 (365 days)
install-on-request: 46,196 (30 days), 127,167 (90 days), 470,559 (365 days)
build-error: 0 (30 days)
brew info php
php: stable 8.0.3 (bottled), HEAD
General-purpose scripting language
https://www.php.net/
/usr/local/Cellar/php/8.0.3 (499 files, 77.8MB)
  Poured from bottle on 2021-04-06 at 23:50:04
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/php.rb
License: PHP-3.01
==> Dependencies
Build: httpd, pkg-config
Required: apr, apr-util, argon2, aspell, autoconf, curl, freetds, gd, gettext, glib, gmp, icu4c, krb5, libffi, libpq, libsodium, libzip, oniguruma, openldap, openssl@1.1, pcre2, sqlite, tidy-html5, unixodbc
==> Options
--HEAD
    Install HEAD version
==> Caveats
To enable PHP in Apache add the following to httpd.conf and restart Apache:
    LoadModule php_module /usr/local/opt/php/lib/httpd/modules/libphp.so

    
        SetHandler application/x-httpd-php
    

Finally, check DirectoryIndex includes index.php
    DirectoryIndex index.php index.html

The php.ini and php-fpm.ini file can be found in:
    /usr/local/etc/php/8.0/

To have launchd start php now and restart at login:
  brew services start php
Or, if you don't want/need a background service you can just run:
  php-fpm
==> Analytics
install: 43,657 (30 days), 154,395 (90 days), 633,561 (365 days)
install-on-request: 42,998 (30 days), 151,518 (90 days), 615,374 (365 days)
build-error: 0 (30 days)
brew info openssl
openssl@1.1: stable 1.1.1k (bottled) [keg-only]
Cryptography and SSL/TLS Toolkit
https://openssl.org/
/usr/local/Cellar/openssl@1.1/1.1.1k (8,071 files, 18.5MB)
  Poured from bottle on 2021-04-05 at 18:15:50
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/openssl@1.1.rb
License: OpenSSL
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/openssl@1.1/certs

and run
  /usr/local/opt/openssl@1.1/bin/c_rehash

openssl@1.1 is keg-only, which means it was not symlinked into /usr/local,
because macOS provides LibreSSL.

If you need to have openssl@1.1 first in your PATH, run:
  echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> ~/.zshrc

For compilers to find openssl@1.1 you may need to set:
  export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
  export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"

==> Analytics
install: 896,790 (30 days), 2,477,217 (90 days), 8,979,457 (365 days)
install-on-request: 75,558 (30 days), 315,157 (90 days), 1,256,762 (365 days)
build-error: 0 (30 days)
openssl version -a
LibreSSL 2.8.3
built on: date not available
platform: information not available
options:  bn(64,64) rc4(16x,int) des(idx,cisc,16,int) blowfish(idx) 
compiler: information not available
OPENSSLDIR: "/private/etc/ssl"
openssl ciphers
ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-CHACHA20-POLY1305:GOST2012256-GOST89-GOST89:DHE-RSA-CAMELLIA256-SHA256:DHE-RSA-CAMELLIA256-SHA:GOST2001-GOST89-GOST89:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA:CAMELLIA256-SHA256:CAMELLIA256-SHA:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-CAMELLIA128-SHA256:DHE-RSA-CAMELLIA128-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:CAMELLIA128-SHA256:CAMELLIA128-SHA:ECDHE-RSA-RC4-SHA:ECDHE-ECDSA-RC4-SHA:RC4-SHA:RC4-MD5:ECDHE-RSA-DES-CBC3-SHA:ECDHE-ECDSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:DES-CBC3-SHA
sudo nginx -t
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
which -a php-fpm
/usr/local/sbin/php-fpm
/usr/sbin/php-fpm
/usr/local/opt/php/sbin/php-fpm -v
PHP 8.0.3 (fpm-fcgi) (built: Mar  4 2021 20:45:30)
Copyright (c) The PHP Group
Zend Engine v4.0.3, Copyright (c) Zend Technologies
sudo /usr/local/opt/php/sbin/php-fpm -y /usr/local/etc/php/7.4/php-fpm.conf --test
[07-Apr-2021 00:09:16] ERROR: failed to open configuration file '/usr/local/etc/php/7.4/php-fpm.conf': No such file or directory (2)
[07-Apr-2021 00:09:16] ERROR: failed to load configuration file '/usr/local/etc/php/7.4/php-fpm.conf'
[07-Apr-2021 00:09:16] ERROR: FPM initialization failed
ls -al ~/Library/LaunchAgents | grep homebrew
-rw-r--r--   1 daudi  staff   657 Apr  6 23:44 homebrew.mxcl.dnsmasq.plist
-rw-r--r--   1 daudi  staff   541 Apr  5 20:08 homebrew.mxcl.mariadb.plist
-rw-r--r--   1 daudi  staff   571 Apr  6 23:45 homebrew.mxcl.nginx.plist
-rw-r--r--   1 daudi  staff   636 Apr  6 23:45 homebrew.mxcl.php@7.4.plist
-rw-r--r--   1 daudi  staff   823 Mar 28 14:27 homebrew.mxcl.redis.plist
ls -al /Library/LaunchAgents | grep homebrew

ls -al /Library/LaunchDaemons | grep homebrew
-rw-r--r--   1 root  admin   657 Apr  6 23:58 homebrew.mxcl.dnsmasq.plist
-rw-r--r--   1 root  admin   571 Apr  6 23:58 homebrew.mxcl.nginx.plist
-rw-r--r--   1 root  admin   628 Apr  6 23:55 homebrew.mxcl.php.plist
-rw-r--r--   1 root  admin   636 Apr  5 18:40 homebrew.mxcl.php@7.3.plist
-rw-r--r--   1 root  admin   636 Apr  6 23:58 homebrew.mxcl.php@7.4.plist
ls -al /Library/LaunchDaemons | grep "com.laravel.valet."

ls -aln /etc/resolv.conf
lrwxr-xr-x  1 0  0  22 Jan  1  2020 /etc/resolv.conf -> ../var/run/resolv.conf
cat /etc/resolv.conf
#
# macOS Notice
#
# This file is not consulted for DNS hostname resolution, address
# resolution, or the DNS query routing mechanism used by most
# processes on this system.
#
# To view the DNS configuration used by this system, use:
#   scutil --dns
#
# SEE ALSO
#   dns-sd(1), scutil(8)
#
# This file is automatically generated.
#
search zuku.co.ke
nameserver 41.212.0.100
nameserver 41.212.0.101
ifconfig lo0
lo0: flags=8049 mtu 16384
    options=1203
    inet 127.0.0.1 netmask 0xff000000 
    inet6 ::1 prefixlen 128 
    inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 
    nd6 options=201
sh -c 'echo "------\n/usr/local/etc/nginx/valet/valet.conf\n---\n"; cat /usr/local/etc/nginx/valet/valet.conf | grep -n "# valet loopback"; echo "\n------\n"'
------
/usr/local/etc/nginx/valet/valet.conf
---

3:    #listen VALET_LOOPBACK:80; # valet loopback

------
sh -c 'for file in ~/.config/valet/dnsmasq.d/*; do echo "------\n~/.config/valet/dnsmasq.d/$(basename $file)\n---\n"; cat $file; echo "\n------\n"; done'
------
~/.config/valet/dnsmasq.d/tld-test.conf
---

address=/.test/127.0.0.1
listen-address=127.0.0.1

------
sh -c 'for file in ~/.config/valet/nginx/*; do echo "------\n~/.config/valet/nginx/$(basename $file)\n---\n"; cat $file | grep -n "# valet loopback"; echo "\n------\n"; done'
------
~/.config/valet/nginx/*
---

cat: /Users/daudi/.config/valet/nginx/*: No such file or directory

------
`
drbyte commented 3 years ago

The Nginx "502 Bad Gateway" (almost) always means PHP isn't running properly. Most of the time the logs will say valet.sock not found, which confirms PHP isn't running properly. This (almost) always means you've got conflicting versions running.

If you look at the LaunchAgents output, you'll see that you have all of Valet's services starting as local user .... but then valet needs to (and automatically does) run all those as root. But since you've manually started all the services as non-root the processes are clashing and permissions don't match and thus files aren't found properly, so you get all these weird symptoms.

Run:

valet stop
brew services stop dnsmasq
brew services stop nginx
brew services stop php@7.4
valet restart dnsmasq
valet start

And then stop starting dnsmasq/nginx/php (of any version) without sudo. In fact, best not to use any brew commands with those apps, but rather use valet commands instead.

DaudiMuriu commented 3 years ago

Thanks for the quick reply. I have been able to finally solve the issue by using your answer together with the reply from @quintenbuis.

Ok got it working!

Here is my command history. Remove all php traces and the walk through the install guide https://laravel.com/docs/8.x/valet#installation

Maybe this happened because I skipped the brew install php Or my php stuff was stained by https://github.com/weprovide/valet-plus

10319  sudo rm -rf /usr/local/Cellar/php
10320  sudo rm -rf /usr/local/Cellar/php*
10321  valet use php@7.4
10322  brew uninstall php@7.4
10325  sudo rm -rf /usr/local/etc/php
10326  brew uninstall php@7.4
10327  brew install php
10332  composer global update laravel/valet
10333  valet install
10334  valet use php@8.0
10335  valet use php@7.4
10336  valet use php@8.0

Also @drbyte point to note since things are now working as expected the LaunchAgents output is still indicating that the services are starting as local user

drbyte commented 3 years ago

the LaunchAgents output is still indicating that the services are starting as local user

ls -al ~/Library/LaunchAgents | grep homebrew should NOT show nginx/dnsmasq/php@X They should only show in ls -al /Library/LaunchDaemons | grep homebrew

It's worth running brew services cleanup to delete orphaned non-root processes. And also get rid of old stuff with brew cleanup

Mohammed-Alama commented 3 years ago

I know it's late but my solution was to delete nginx , all php version , dnsmask and start to install it as fresh setup , and for using multi version of php i use this bash script from @freekmurze Switch PHP Version but the problem with this way is the composer global update cuz limitation of of check platform when using version less than php@7.3

PhillipMwaniki commented 2 years ago

Here is a solution that works well, both in production and development, in your nginx config for the site, add the following lines on the second server block

        fastcgi_connect_timeout 75;
        fastcgi_send_timeout 600;
        fastcgi_read_timeout 600;
        fastcgi_buffers 32 256k;
        fastcgi_buffer_size 512k;
4goodapp commented 2 years ago

Had same issues, @quintenbuis solution worked fine.

JohnnyWalkerDigital commented 1 year ago

My Valet was trying to use PHP 8.2 (I checked via valet links).

I ran valet use php@8.1 --force and everything was fine again.