Laravel 代客不工作
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37135711/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel valet not working
提问by metylbk
I use OSX El Capitan and PHP 7. I followed the installation guide so I install Laravel Valet version v1.1.3 successfully. I ping foo.dev or any.dev then the terminal prints
我使用 OSX El Capitan 和 PHP 7。我按照安装指南成功安装了 Laravel Valet 版本 v1.1.3。我 ping foo.dev 或 any.dev 然后终端打印
"64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.116 ms"
Everything is ok. My directory /User/mickey/Sites
is added to Valet's paths. I created a Laravel 5.2 project named blog, then run the project with php artisan serve
ok but when i accessed url blog.dev on the browser, the browser said
一切都好。我的目录/User/mickey/Sites
被添加到 Valet 的路径中。我创建了一个名为 blog 的 Laravel 5.2 项目,然后用php artisan serve
ok运行该项目但是当我在浏览器上访问 url blog.dev 时,浏览器说
This site can't be reached, blog.dev refused to connect. ERR_CONNECTION_REFUSED.
无法访问此站点,blog.dev 拒绝连接。ERR_CONNECTION_REFUSED。
I don't know what is the problem with my installation. Thanks in advance!
我不知道我的安装有什么问题。提前致谢!
回答by Ben Swinburne
You needn't run php artisan serve
as Valet runs Caddy in the background.
您无需运行,php artisan serve
因为 Valet 在后台运行 Caddy。
Here're a few troubleshooting points.
以下是一些故障排除要点。
Ensure that you don't have Apache (or anything else running on port 80)
sudo apachectl stop
Ensure that Valet is running
valet start
Ensure that PHP was installed with FPM
brew uninstall homebrew/php/php70
brew install homebrew/php/php70 --with-fpm
确保您没有 Apache(或在端口 80 上运行的任何其他东西)
sudo apachectl stop
确保 Valet 正在运行
valet start
确保 PHP 与 FPM 一起安装
brew uninstall homebrew/php/php70
brew install homebrew/php/php70 --with-fpm
回答by Manuel Fodor
After trying everything I found on the internet (including this onewhich worth to try) for me the solution was to change valet's domain to test
.
乱投医后,我在互联网(包括上找到这一个值得一试它)对我来说,解决办法是改变男仆的域名test
。
valet domain test
valet domain test
So I have no idea if the mentioned reinstall was needed or not but I know that I could ping
or even curl
my .dev
sites but could not open them in any browser (Chrome nor Safari). Then I tried to set domain to .app
but that did not work either. In the browsers I was redirected all the time to https
even after running valet unsecure
.
所以我不知道是否需要提到的重新安装,但我知道我可以ping
,甚至curl
我的.dev
网站,但无法在任何浏览器(Chrome 或 Safari)中打开它们。然后我尝试将域设置为,.app
但这也不起作用。在浏览器中,https
即使在运行valet unsecure
.
But then changed domain to .test
and suddenly it started to work. I'm not sure what is the real issue here and why is this but I'm okay with it since it works again.
但随后将域更改为.test
并突然开始工作。我不确定这里的真正问题是什么,为什么会这样,但我可以接受,因为它又可以工作了。
I've also read that .dev
is not good any more because it's an official TLD and so reserved. (wikipedia)
我也读过这.dev
不再是好的,因为它是官方 TLD,因此被保留。(维基百科)
回答by rjb
I had nearly the same issue of Laravel Valet not working after installing via Homebrew on macOS 10.13 "High Sierra".
在 macOS 10.13“High Sierra”上通过 Homebrew 安装后,我遇到了几乎相同的 Laravel Valet 无法工作的问题。
The problem I encountered was that DNSMasq would respond to queries, but Nginx would not handle the responses on port 80.
我遇到的问题是 DNSMasq 会响应查询,但 Nginx 不会处理端口 80 上的响应。
Attempting to connect to the site in a Terminal session would result in the following error:
尝试在终端会话中连接到站点会导致以下错误:
$ curl -IL http://example.test/
curl: (7) Failed to connect to example.test port 80: Connection refused
I had recently upgraded from macOS 10.2 "Sierra" to 10.13 "High Sierra", so I suspected my Homebrew environment and configuration that was brought by the Migration Assistant could be at fault.
我最近从 macOS 10.2 "Sierra" 升级到 10.13 "High Sierra",所以我怀疑我的 Homebrew 环境和迁移助手带来的配置可能有问题。
While following the troubleshooting advice here and elsewhere, what eventually solved my problem was to completely uninstall and remove Valet along with its dependencies (PHP, Nginx, DNSMasq, etc):
在遵循此处和其他地方的故障排除建议时,最终解决我的问题的是完全卸载并删除 Valet 及其依赖项(PHP、Nginx、DNSMasq 等):
$ rm -rf ~/.valet
$ brew unlink nginx && brew remove nginx
$ brew unlink php56 && brew remove php56 && brew uninstall --ignore-dependencies php56
$ brew unlink php72 && brew remove php72
$ brew unlink dnsmasq && brew remove dnsmasq
With a clean slate, I was able to successfully install Valet:
有了干净的石板,我能够成功安装 Valet:
$ brew update
$ brew install homebrew/core/php
$ composer global require laravel/valet
$ valet install
I then setup a new development domain:
然后我设置了一个新的开发域:
$ valet domain test
$ valet park ~/Sites
$ mkdir ~/Sites/example && cd "$_"
$ valet link
$ echo "Hello, world" > ~/Sites/example/index.html
With Valet installed, I verified everything was working:
安装 Valet 后,我验证了一切正常:
$ valet --version
$ sudo nginx -t
$ ping -c 4 example.test
$ curl -IL http://example.test/
$ valet open example
After doing all of this, I had a 100% successful working Laravel Valet environment.
在完成所有这些之后,我拥有一个 100% 成功的 Laravel Valet 环境。
回答by Rick Bolton
Hopefully I can now solve this one for you. The Self Control fix worked as a temp fix for me so you may be in luck as I've found a permanent solution for me!
希望我现在可以为您解决这个问题。自我控制修复对我来说是一个临时修复,所以你可能很幸运,因为我为我找到了一个永久的解决方案!
I once had a httpd setup which I followed a guide to install. This came with some baggage as the guide got you to forward 127.0.0.1 port 80 to port 8080.
我曾经有一个 httpd 设置,我按照指南进行安装。这附带了一些行李,因为指南让您将 127.0.0.1 端口 80 转发到端口 8080。
Try this anyway Go > Go to folder...
无论如何试试这个 Go > Go to folder...
/Library/LaunchDaemons/
/图书馆/LaunchDaemons/
The file in my case was called co.echo.httpdfwd.plist which I just needed to delete and then restart my Mac. See my question for more info Laravel Valet not working. 127.0.0.1 Connection Refused.
在我的案例中,该文件名为 co.echo.httpdfwd.plist,我只需要删除它,然后重新启动我的 Mac。有关详细信息,请参阅我的问题Laravel Valet 不工作。127.0.0.1 连接被拒绝。
Let me know how you get on!
让我知道你是怎么办的!
回答by metylbk
The problem was solved by starting self-control app. I don't know the reason but you can try to download and start this app to resolve this problem.
问题是通过启动自控应用程序解决的。我不知道原因,但您可以尝试下载并启动此应用程序来解决此问题。