代客(Laravel):找不到DNS地址 [英] Valet (Laravel): DNS address can not be found

查看:74
本文介绍了代客(Laravel):找不到DNS地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在试用Valet,从我所听到的来看,它看起来真的很不错.

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.

但是当我cd进入我的项目文件并输入valet park并浏览到http://blog.dev时,我得到找不到blog.dev的DNS服务器地址."

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."

我不知道我在做什么错. :)

I have no idea what I'm doing wrong. :)

推荐答案

当您运行valet install时,它将尝试安装dnsmasq.它需要sudo权限.

When you run valet install it attempts to install dnsmasq. It requires sudo privileges.

您可以使用来检查它是否已安装并正在运行

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 tap homebrew/services

如果不存在,请运行

brew install dnsmasq
brew services start dnsmasq

再次运行valet install来设置dnsmasq,并注意是否有任何错误.这应该做的是在/usr/local/etc/dnsmasq.conf的底部添加一行,类似于

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

conf-file=/Users/{YOURUSER}/.valet/dnsmasq.conf

然后

/Users/{YOURUSER}/.valet/dnsmasq.conf应该包含

/Users/{YOURUSER}/.valet/dnsmasq.conf then should contain

address=/.dev/127.0.0.1

检查您的dns服务器是否正在响应请求

Check that your dns server is responding to requests

dig testing.dev @127.0.0.1

您应该会看到类似的回复

You should see a response like

;; ANSWER SECTION:
testing.dev. 0 IN   A   127.0.0.1

要真正确保您的Mac知道它应该使用本地DNS服务器解析* .dev,则需要告知它这样做.代客泊车还为您处理此问题,但是您可以通过执行以下操作来检查它是否已完成.

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.

在目录/etc/resolver中,应该有一个名为dev的文件,内容如下:

Inside the directory /etc/resolver, there should be a file entitled dev with the following contents

nameserver 127.0.0.1

这将为* .dev创建一个自定义DNS解析器,并将所有请求指向您的本地DNS服务器.

This creates a custom DNS resolver for *.dev and points all requests at your local DNS server.

使用以下任一命令重新启动dnsmasq,然后重试.

Restart dnsmasq with either of the following commands and then give it a try again.

// this
brew services restart dnsmasq

// or this
sudo launchctl stop homebrew.mxcl.dnsmasq
sudo launchctl start homebrew.mxcl.dnsmasq

如果一切正常,您应该可以ping通任何东西.dev

If this is all working, you should be able to ping anything.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

这可确保与DNS相关的位正常工作.

That ensures the DNS related bits are working.

最终的问题是有关DNS的问题,但是由于这是您需要尝试的所有内容,因此我将其保留在下面.也就是说,如果您无法ping通something.dev或收到类似找不到blog.dev的DNS服务器地址"之类的错误.根据OP,这与DNS有关,需要解决.

由于Caddy在端口80上提供网站服务,因此您需要确保端口80上没有其他任何运行.

Since Caddy serves websites on port 80, you need to ensure that nothing else is running on port 80.

sudo lsof -n -i:80 | grep LISTEN

理想情况下,如果代客按预期运行,这应该返回caddy.您想查看下面的示例,或者理想情况下什么也不做;没什么,因为这意味着我们可以启动Valet.

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.

caddy     76234 root    3u  IPv6 0x4f871f962e84fa95      0t0  TCP *:http (LISTEN)

在下面的示例中,您可能会看到其他Web服务器,例如Apache或Nginx(及其子进程,_wwwnobody).

You may see other webservers, such as Apache or Nginx (and their child processes, _www and nobody) in the example below.

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)

假设您已经用自制软件安装了Nginx,则可以运行以下命令将其停止.

Assuming you've installed Nginx with homebrew you can run the following to stop it.

brew services stop nginx

OSX附带安装了Apache,因此,如果正在运行,则可以停止以下操作.

OSX ships with Apache installed so you can stop with with the following if it's running.

sudo apachectl stop

在这一点上,您可以从valet start开始代客交易,并且可以使用.

At this point you can likely start Valet with valet start and it'll work.

您可能会收到进一步的错误,该错误是由于未安装FPM而安装PHP引起的.您可以使用

You may get a further error which is caused by PHP being installed without FPM. You can check this using

brew info php70 | grep php70-fpm

哪些应该产生类似的东西

Which should yield something along the lines of

控制脚本位于/usr/local/opt/php70/sbin/php70-fpm

The control script is located at /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

这篇关于代客(Laravel):找不到DNS地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆