Closed Mohammed-Alama closed 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
.
Having the same issue here
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.
@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.
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
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.
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
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
`
ProductName: macOS ProductVersion: 11.2.3 BuildVersion: 20D91
Laravel Valet 2.14.1
{ "tld": "test", "loopback": "127.0.0.1", "paths": [] }
{ "require": { "laravel/installer": "^4.2", "laravel/valet": "^2.14" } }
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
Changed current directory to /Users/daudi/.composer psr/container 1.1.1 ~ 2.0.1 Common Container Interface (PHP FIG PSR-11)
total 0 drwxr-xr-x 2 root wheel 64 Jan 1 2020 . drwxr-xr-x 86 root wheel 2752 Apr 6 23:25 ..
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
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
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
homebrew/core homebrew/services shivammathur/php
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
/usr/local/bin/php /usr/bin/php
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 version: nginx/1.19.8
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
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
ngrok version 2.3.35
ls: /Users/daudi/.ngrok2: No such file or directory
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)
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.soSetHandler 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)
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)
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"
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
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
/usr/local/sbin/php-fpm /usr/sbin/php-fpm
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
[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
-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
-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
lrwxr-xr-x 1 0 0 22 Jan 1 2020 /etc/resolv.conf -> ../var/run/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
lo0: flags=8049mtu 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
------ /usr/local/etc/nginx/valet/valet.conf --- 3: #listen VALET_LOOPBACK:80; # valet loopback ------
------ ~/.config/valet/dnsmasq.d/tld-test.conf --- address=/.test/127.0.0.1 listen-address=127.0.0.1 ------
------ ~/.config/valet/nginx/* --- cat: /Users/daudi/.config/valet/nginx/*: No such file or directory ------
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.
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-plus10319 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
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
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
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;
Had same issues, @quintenbuis solution worked fine.
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.
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.plistOutput of these steps
Possible solution
Diagnosis
sw_vers
valet --version
cat ~/.config/valet/config.json
cat ~/.composer/composer.json
composer global diagnose
composer global outdated
ls -al /etc/sudoers.d/
brew config
brew services list
brew list --formula --versions | grep -E "(php|nginx|dnsmasq|mariadb|mysql|mailhog|openssl)(@\d\..*)?\s"
brew outdated
brew tap
php -v
which -a php
php --ini
nginx -v
curl --version
php --ri curl
~/.composer/vendor/laravel/valet/bin/ngrok version
ls -al ~/.ngrok2
brew info nginx
brew info php
brew info openssl
openssl version -a
openssl ciphers
sudo nginx -t
which -a php-fpm
/usr/local/opt/php/sbin/php-fpm -v
sudo /usr/local/opt/php/sbin/php-fpm -y /usr/local/etc/php/8.0/php-fpm.conf --test
ls -al ~/Library/LaunchAgents | grep homebrew
ls -al /Library/LaunchAgents | grep homebrew
ls -al /Library/LaunchDaemons | grep homebrew
ls -al /Library/LaunchDaemons | grep "com.laravel.valet."
ls -aln /etc/resolv.conf
cat /etc/resolv.conf
ifconfig lo0
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"'
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'
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'