Hi,
So I'm developing a Laravel + Vue app, and I'm getting to the point where Homestead is a little too slow. I decided to give Valet a go, and haven't been able to get it off the ground.
Composer Installs successfully, no errors on install whatsoever.
However, when I go to valet install I get the following:
PHP Notice: Undefined index: domain in /Users/kingsley/.composer/vendor/laravel/valet/cli/Valet/Nginx.php on line 111
Notice: Undefined index: domain in /Users/kingsley/.composer/vendor/laravel/valet/cli/Valet/Nginx.php on line 111
One Laracast forum post mentioned to link or park a domain, so I tried linking my Laravel app, but when I go to visit the URL in the browser I get:
Notice: Undefined index: domain in /Users/kingsley/.composer/vendor/laravel/valet/server.php on line 55
404 - Not Found
I'm not sure what other info may help, but Brew is up-to-date, php -v returns v 7.1.0
I'm not sure if it's related, but when I run nginx, I get:
nginx: [warn] the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /usr/local/etc/nginx/nginx.conf:1
nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)
Does anyone have any idea? Thanks
FIXED.
To anyone else having a similar problem, I'm not sure on the exact issue but I believe it was something to do with Brew, and permissions with nginx and dnsmasq.
Before installing valet, make sure php71, dnsmasq, nginx, are installed and running ok by using brew services:
brew services list
Which should be:
dnsmasq started root /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
mariadb started kingsley /Users/kingsley/Library/LaunchAgents/homebrew.mxcl.mariadb.plist
nginx started root /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
php71 started root /Library/LaunchDaemons/homebrew.mxcl.php71.plist
If you see error under any of them, stop all the services by running:
```
brew services stop --all
sudo brew services stop --all
I think I had nginx started under my user account AND under root (2 running instances).
Restart php, nginx, and dnsmasq as root:
sudo brew services start php71
sudo brew services start dnsmasq
sudo brew service start nginx
Completely remove all valet files in ~/.valet
composer global remove laravel/valet
rm -rf ~/.valet
Then install valet
composer global require laravel/valet
valet install
```
Hopefully that'll do the trick!
Thanks a lot.
@tintamarre, you're welcome! It cost me 2 solid days so glad it helped
I spent two hours trying to find out what was going on until I found this issue. :-)
thanks a lot.
Nginx needs to be run as root, as does DNSMasq.
(Deleted my comment above about not running it as root)
Oh sorry then... ignore me. Any reason why its working correctly here? Will something break if I dont?
Nginx can't bind to port 80 unless it's run as root, so nothing should work, haha...
I would check ps aux | grep nginx and see if it actually is running as your user and not as root.
So it is... Looks like it didnt actually stop nginx on my system so it appeared to work. Brew seems to incorrectly report that it stopped/started a service successfully which led to my confusion.
I'm almost positive you had it running with the incorrect permissions.
You can probably confirm by comparing:
brew services list
sudo brew services list
I encountered this exact issue and want to let anybody else know that the above solutions didn't work for me.
However the issue that I had was that I forgot to urlencode some parameters in a GET request. Basically I had a semicolon and a number at the end of the url (passed in a datetime as a parameter) and it caused Valet to break this exact same way.
I'm also encountering this issue. Suggested solution doesn't seem to work 😟
@kasparasg, have you tried this?
brew services list
sudo brew services list
I'm a bit out of touch with this issue now as my solution fixed it for me. I'd just double check permissions, which user accounts are running what, and do one last uninstall, clean up composer, and do a fresh install. Sorry I can't be of any help!
I'll give it ago.. It's definitely some permission thing going on. I don't even have .valet dir created under my user account. When I do valet install it asks for admin password. The .valet directory is created under root. Odd 🤔 Never really had an issue with Valet.
Could it be composer? Composer was installed under the wrong account?
hmm, I'm gonna double check. But I typically never run anything under sudo and I'm pretty cautious about it. I'll keep digging. I'll write it up if I find a solution.
Is it normal that .valet directory is created under /var/root/?
When I install valet and run valet install it right away asks for sudo rights, I guess that's expected?
My nginx service is giving bad gateway errors. Also I'm seeing this:
→ nginx
nginx: [warn] the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /usr/local/etc/nginx/nginx.conf:1
nginx: [emerg] open() "/var/root/.valet/Log/nginx-error.log" failed (13: Permission denied)
Nginx user runs as my user and not root.
Anyone else having these issues? I've reinstall composer, everything. Not sure what else I should try?
@kasparasg My .valet is in my home directory. You probably have issued sudo while trying to install Valet.
What you can do is changing permission for valet so that you need not run with sudo.
@ruchern hmm. But valet install asks for sudo 🤔
It asks for sudo to configure nginx, Valet itself should not be installed as sudo.
@adamwathan hmm... yeah, not sure what the hell happened. I'll keep digging. I've noticed that when I brew install php71, under brew services list, php71 is started as sudo... That doesn't feel right to me 🤔
Never ran into these issues before, been using Valet for quite some time since 1.
@adamwathan I think I'm having the same issue as these guys here #321. As it somehow runs php scripts with sudo privileges causing the .valet directory to end up in /var/root 🤔
I had to additionally re-install dnsmasq.
I think that this could be easily fixed just by adding "domain": "dev" on your …/.valet/config.json file.
It somehow works for me now. And .valet is in my home dir. But every time I run valet command it asks for sudo, odd. .valet dir is owned by a user as well as valet cli.
@kasparasg Valet runs commands that require sudo access, such as restarting nginx.
@joshmanders sure. Would you expect to be asked for password when you valet link or valet logs ? If that's the expected behaviour - I'm with with it. Just want to make sure it's not just me 😄
Most helpful comment
FIXED.
To anyone else having a similar problem, I'm not sure on the exact issue but I believe it was something to do with Brew, and permissions with nginx and dnsmasq.
Before installing valet, make sure php71, dnsmasq, nginx, are installed and running ok by using brew services:
brew services listWhich should be:
If you see error under any of them, stop all the services by running:
```
brew services stop --all
sudo brew services stop --all
sudo brew services start php71
sudo brew services start dnsmasq
sudo brew service start nginx
composer global remove laravel/valet
rm -rf ~/.valet
composer global require laravel/valet
valet install
```
Hopefully that'll do the trick!