127.0.0.1 和 localhost 在使用 macports 安装的雪豹上不同
在通过 macports 升级到最新的 PHP 后,我一整天都在试图解决这个问题。虽然现在我有一个奇怪的问题,如果我访问 http://localhost - 这可以正确显示我的网站 /Users/foo/Sites 中的网站列表 http://127.0.0.1 - 这显示默认的“It Works”
我已经使用以下内容创建了一个虚拟主机文件
<VirtualHost *>
DocumentRoot "/Users/foo/Sites"
ServerName localhost
ServerAlias 127.0.0.1
ServerAdmin [email protected]
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /Users/foo/Sites>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /opt/local/apache2/logs/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /opt/local/apache2/logs/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/Users/foo/Sites/snow"
ServerName snow.local
ServerAlias www.snow.local
ErrorLog "/opt/local/apache2/logs/snow-error_log"
CustomLog "/opt/local/apache2/logs/snow-access_log" common
</VirtualHost>
我的主机文件包含
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 snow.local
I have been trying to figure this out all day after upgrading to the latest PHP via macports. Although now I have a strange problem in that if I visit
http://localhost - this works correct displaying a list of websites in my sites /Users/foo/Sites
http://127.0.0.1 - this displays the default "It Works"
I havw I have created a vhost file with the following
<VirtualHost *>
DocumentRoot "/Users/foo/Sites"
ServerName localhost
ServerAlias 127.0.0.1
ServerAdmin [email protected]
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /Users/foo/Sites>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /opt/local/apache2/logs/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /opt/local/apache2/logs/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/Users/foo/Sites/snow"
ServerName snow.local
ServerAlias www.snow.local
ErrorLog "/opt/local/apache2/logs/snow-error_log"
CustomLog "/opt/local/apache2/logs/snow-access_log" common
</VirtualHost>
My host file contains
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 snow.local
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我总是必须去 http://localhost/~MY_USERNAME
I alwways have to go to http://localhost/~MY_USERNAME
找到了问题的答案。这是由于打开了“网络共享”设置造成的。
Found the answer to the problem. This was caused due to having the 'web sharing' settings turned on.