代客 (Laravel):找不到 DNS 地址
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37172691/
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
Valet (Laravel): DNS address can not be found
提问by sseraluck
I'm trying out Valet, it looks really nice from what I've heard.
我正在试用 Valet,据我所知,它看起来非常好。
I've been trough the "whole" installation process, Valet is succesfully installed.
我已经完成了“整个”安装过程,Valet 已成功安装。
But when I cd
into my projects file and enter valet park
and browse to http://blog.dev
, I get "The DNS server address of blog.dev can not be found."
但是当我cd
进入我的项目文件并输入valet park
并浏览到时http://blog.dev
,我得到“找不到 blog.dev 的 DNS 服务器地址”。
I have no idea what I'm doing wrong. :)
我不知道我做错了什么。:)
回答by Ben Swinburne
When you run valet install
it attempts to install dnsmasq. It requires sudo privileges.
当您运行时,valet install
它会尝试安装 dnsmasq。它需要 sudo 权限。
You can check that it's installed and running using
您可以使用以下命令检查它是否已安装并正在运行
brew services list
You should see something like
你应该看到类似的东西
dnsmasq started root /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
You may however need to tap brew/services first
但是,您可能需要先点击 brew/services
brew tap homebrew/services
If it's not there, run
如果它不存在,请运行
brew install dnsmasq
brew services start dnsmasq
Run valet install
again to set up dnsmasq and keep an eye out for any errors. What this should do is append a line to the bottom of /usr/local/etc/dnsmasq.conf similar to
valet install
再次运行以设置 dnsmasq 并留意任何错误。这应该做的是在 /usr/local/etc/dnsmasq.conf 的底部附加一行类似于
conf-file=/Users/{YOURUSER}/.valet/dnsmasq.conf
/Users/{YOURUSER}/.valet/dnsmasq.conf then should contain
/Users/{YOURUSER}/.valet/dnsmasq.conf 然后应该包含
address=/.dev/127.0.0.1
Check that your dns server is responding to requests
检查您的 dns 服务器是否正在响应请求
dig testing.dev @127.0.0.1
You should see a response like
你应该看到这样的回应
;; ANSWER SECTION:
testing.dev. 0 IN A 127.0.0.1
To actually ensure that your Mac knows that it should resolve *.dev using your local DNS server, it need to be told to do so. Valet also handles this for you but you can check if it's done it's job by doing the following.
要真正确保您的 Mac 知道它应该使用本地 DNS 服务器解析 *.dev,需要告诉它这样做。Valet 也会为您处理此问题,但您可以通过执行以下操作来检查它是否已完成。
Inside the directory /etc/resolver
, there should be a file entitled dev
with the following contents
在目录里面/etc/resolver
,应该有一个文件名dev
,内容如下
nameserver 127.0.0.1
This creates a custom DNS resolver for *.dev and points all requests at your local DNS server.
这会为 *.dev 创建自定义 DNS 解析器,并将所有请求指向本地 DNS 服务器。
Restart dnsmasq with either of the following commands and then give it a try again.
使用以下任一命令重新启动 dnsmasq,然后再试一次。
// this
brew services restart dnsmasq
// or this
sudo launchctl stop homebrew.mxcl.dnsmasq
sudo launchctl start homebrew.mxcl.dnsmasq
If this is all working, you should be able to ping anything.dev
如果这一切正常,您应该可以 ping 任何东西.dev
ping anything.dev
PING anything.dev (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.039 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.081 ms
That ensures the DNS related bits are working.
这可确保 DNS 相关位正常工作。
Ultimately the question is about DNS related problems but as this started off as a here's everything you need to have tried, I'll leave this below. That said, if you're unable to ping something.dev or get an error like "The DNS server address of blog.dev can not be found." as per the OP, it's something above to do with DNS which needs resolving.
最终的问题是与 DNS 相关的问题,但由于这是您需要尝试的所有内容,因此我将把它留在下面。也就是说,如果您无法 ping something.dev 或收到诸如“找不到 blog.dev 的 DNS 服务器地址”之类的错误。根据OP,上面的内容与需要解析的DNS有关。
Since Caddy serves websites on port 80, you need to ensure that nothing else is running on port 80.
由于 Caddy 在端口 80 上为网站提供服务,因此您需要确保端口 80 上没有其他任何东西在运行。
sudo lsof -n -i:80 | grep LISTEN
Ideally this should return caddy if valet is running as expected. You want to see the example below or nothing ideally; nothing because it means we can just start Valet.
理想情况下,如果代客按预期运行,这应该返回球童。你想看下面的例子,或者什么都不理想;没什么,因为这意味着我们可以启动 Valet。
caddy 76234 root 3u IPv6 0x4f871f962e84fa95 0t0 TCP *:http (LISTEN)
You may see other webservers, such as Apache or Nginx (and their child processes, _www
and nobody
) in the example below.
在下面的示例中,您可能会看到其他网络服务器,例如 Apache 或 Nginx(以及它们的子进程_www
和nobody
)。
httpd 79 root 4u IPv6 0xf4641199930063c5 0t0 TCP *:http (LISTEN)
httpd 239 _www 4u IPv6 0xf4641199930063c5 0t0 TCP *:http (LISTEN)
nginx 4837 root 6u IPv4 0xf4641199a4e8e915 0t0 TCP 127.0.0.1:http (LISTEN)
nginx 4838 nobody 6u IPv4 0xf4641199a4e8e915 0t0 TCP 127.0.0.1:http (LISTEN)
Assuming you've installed Nginx with homebrew you can run the following to stop it.
假设您已经使用自制软件安装了 Nginx,您可以运行以下命令来停止它。
brew services stop nginx
OSX ships with Apache installed so you can stop with with the following if it's running.
OSX 附带安装了 Apache,因此如果它正在运行,您可以停止使用以下命令。
sudo apachectl stop
At this point you can likely start Valet with valet start
and it'll work.
在这一点上,您可能可以开始 Valet,valet start
它会起作用。
You may get a further error which is caused by PHP being installed without FPM. You can check this using
您可能会收到进一步的错误,这是由在没有 FPM 的情况下安装 PHP 引起的。您可以使用
brew info php70 | grep php70-fpm
Which should yield something along the lines of
哪个应该产生一些类似的东西
The control script is located at /usr/local/opt/php70/sbin/php70-fpm
控制脚本位于/usr/local/opt/php70/sbin/php70-fpm
If it doesn't appear to be installed, use the following.
如果似乎没有安装,请使用以下命令。
brew uninstall homebrew/php/php70
brew install homebrew/php/php70 --with-fpm
valet restart
回答by FQuist
I had the same problem - getting stuck at ping foobar.dev - and fixed it by restarting my Macbook (after valet install). I am sure this is not an exact solution and I reckon there is a way to do this without restarting. Yet, it worked for me. I did not have to do any other steps.
我遇到了同样的问题 - 卡在 ping foobar.dev - 并通过重新启动我的 Macbook(代客安装后)修复它。我确信这不是一个确切的解决方案,我认为有一种方法可以在不重新启动的情况下做到这一点。然而,它对我有用。我不必执行任何其他步骤。
[Edit - Additionally, before restarting I made sure to try the installing with fpm tip, and to follow all brew's suggestions upon installing php70 (tweaking the path, making sure php70 starts on system start. I cannot say whether these things helped, so probably want to try just restarting, first. If it's really just a restart that's required, or some other additional step to properly start services, I think the laravel documentation probably needs some clarification.]
[编辑 - 此外,在重新启动之前,我确保尝试使用 fpm 提示进行安装,并在安装 php70 时遵循所有 brew 的建议(调整路径,确保 php70 在系统启动时启动。我不能说这些事情是否有帮助,所以可能想尝试重新启动,首先。如果它真的只是需要重新启动,或者正确启动服务的其他一些额外步骤,我认为laravel文档可能需要一些澄清。]
回答by Nishanth KD
I had the same problem, post installation I got stuck at pinging foo.dev.
我遇到了同样的问题,安装后我被 ping foo.dev 卡住了。
I checked for running services.
我检查了正在运行的服务。
> brew services list
Name Status User Plist
dnsmasq stopped
nginx stopped
php71 stopped
Started all the three services manually with
手动启动所有三个服务
> brew services start dnsmasq
> brew services start nginx
> brew services start php71
Ran valet install
.
冉valet install
。
Ping successfully to foo.dev
Ping 成功到 foo.dev
回答by Malico
If you are a Windows user, Perform the Acrylic Configuration then restart your adapter(Disable and Enable)
如果您是 Windows 用户,请执行 Acrylic 配置,然后重新启动您的适配器(禁用和启用)
http://mayakron.altervista.org/wikibase/show.php?id=AcrylicWindows10Configuration
http://mayakron.altervista.org/wikibase/show.php?id=AcrylicWindows10Configuration
Worked For Me
对我来说有效