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

查看:229
本文介绍了在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.

我已经重新启动服务器,然后浏览到要与Apache的默认页面(而不是我的测试页面)打招呼的测试URL. 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天全站免登陆