我已经将 DNSMasq 配置为使用原生 Apache2、原生 PHP5 和自制 MySQL 和 DNSMasq 的 OSX Yosemite 本地测试服务器。现在一切正常,但是在当前的 DNS 设置下,我只能在其配置中使用 127.0.0.1 访问 PHPMyAdmin,对于每个 WordPress 设置也是如此。主机必须是 127.0.0.1 本地主机不再工作以访问我的本地主机。
这是我的一些配置:
/etc/hosts
:
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
解析器/etc/resolver/dev
:
nameserver 127.0.0.1
在/usr/local/etc/dnsmasq.conf
我补充说:
listen-address=127.0.0.1
address=/dev/127.0.0.1
现在,当我加载 localhost 或http://localhost
得到 404 时:
::1 - - [22/Feb/2015:08:12:33 +0300] "GET / HTTP/1.1" 404 198
Pinging 工作得很好:
ping localhost
PING localhost (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.050 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.106 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.116 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.113 ms
^C
--- localhost ping statistics ---
4 packets transmitted, 4 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.050/0.096/0.116/0.027 ms
我的虚拟主机在/private/etc/apache2/extra/httpd-vhosts.conf
<Virtualhost *:80>
VirtualDocumentRoot "/Users/me/webdesign/%1"
ServerName vhosts.dev
ServerAlias *.dev
UseCanonicalName Off
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
ErrorLog "/Users/me/webdesign/vhosts-error_log"
<Directory "/Users/me/webdesign/*">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</Virtualhost>
在本文中,/etc/apache2/httpd.conf
我在末尾添加了停止启动 Apache 时的错误并使 PHPMYAdmin 在 localhost 上工作。
ServerName localhost
Alias /phpmyadmin /usr/local/share/phpmyadmin
<Directory /usr/local/share/phpmyadmin/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
<IfModule !mod_authz_core.c>
Order allow,deny
Allow from all
</IfModule>
</Directory>
当我运行 scutil 我看到
scutil --dns
DNS configuration
resolver #1
search domain[0] : Home
nameserver[0] : 192.168.1.1
if_index : 4 (en1)
flags : Request A records
reach : Reachable,Directly Reachable Address
resolver #2
domain : dev
nameserver[0] : 127.0.0.1
flags : Request A records, Request AAAA records
reach : Reachable,Local Address
DNS configuration (for scoped queries)
resolver #1
search domain[0] : Home
nameserver[0] : 192.168.1.1
if_index : 4 (en1)
flags : Scoped, Request A records
reach : Reachable,Directly Reachable Address
有什么想法可以让 localhost 再次工作吗?