在 Mac 上的 XAMPP 上设置虚拟主机 [英] Setting up a virtual host on XAMPP on Mac

查看:32
本文介绍了在 Mac 上的 XAMPP 上设置虚拟主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在本地主机上的苹果 mac 上设置虚拟主机.服务器由 XAMPP 提供,它将 Apache/MySQL/PHP 捆绑在一个包中.

I am trying to set up a virtualhost on my apple mac on localhost. The server is provided by XAMPP, which bundles Apache/MySQL/PHP in one bundle.

这是我到目前为止所做的:

Here is what I have done so far:

编辑/private/etc/hosts 以包含 127.0.0.1 以指向 test.myserver.local

Edited /private/etc/hosts to include 127.0.0.1 to point to test.myserver.local

127.0.0.1       test.myserver.local

编辑/Applications/XAMPP/etc/extra/httpd-vhosts.conf 以包含我的虚拟主机详细信息

Edited /Applications/XAMPP/etc/extra/httpd-vhosts.conf to inlcude my vhosts details

<VirtualHost *:80>
   DocumentRoot /Users/???/Documents/workspace/trunk/htdocs
   ServerName test.myserver.local
  <Directory "/Users/???/Documents/workspace/trunk/htdocs">
     AllowOverride All
  </Directory>
</VirtualHost>

在其中放置了一个简单的 index.html,其中包含 test 一词.

Placed a simple index.html in there with the word test in it.

我已经重新启动了服务器,然后浏览到测试 url 以迎接 Apache 的默认页面而不是我的测试页面.vhosts 文件适用于另一个虚拟主机,复制代码时更改了相应的位(即文件夹路径),hosts 文件有效,当 Apache 关闭时,我的浏览器显示找不到服务器.

I have restarted the server, and then browse to the test url to be greeted with Apache's default page instead of my test page. The vhosts file works for another virtual host, the code is copied with the respective bits changed (i.e. folder paths), the hosts file works, as when Apache is turned off, my browser says server not found.

为什么 Apache 拒绝显示我的测试代码?我还需要更改其他文件吗?我想不出任何其他的,它通常只是那些在 linux/windows 上的.

Why is Apache refusing to show up my test code? Are there any other files I need to change? I cant think of any others, its usually just those on linux/windows.

推荐答案

你有没有告诉 Apache 实际使用基于名称的虚拟主机?

Have you told Apache to actually use name-based virtual hosting?

# Use name-based virtual hosting.
#
NameVirtualHost *:80

我不相信它在 Mac 上的 Xampp 中默认启用.

I don't believe it's enabled by default in Xampp on Mac.

这篇关于在 Mac 上的 XAMPP 上设置虚拟主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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