【问题标题】:virtual host for xampp on MacMac 上 xampp 的虚拟主机
【发布时间】:2020-09-11 00:59:50
【问题描述】:

在我的 macos 10.15.4 上的 httpd-vhost.conf 中,



<VirtualHost *:80>
    DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/"
    ServerName localhost

</VirtualHost>


<VirtualHost *:80>
    DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/theb/"
    ServerName theb.localhost
    ServerAlias www.theb.localhost
    #DirectoryIndex index.html
    <Directory "/Applications/XAMPP/xamppfiles/htdocs/theb">
        Require all granted              
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride none
    </Directory>
    ErrorLog "logs/theb.local-error_log"
</VirtualHost>

我还在 httpd.conf 中包含了虚拟主机

Include etc/extra/httpd-vhosts.conf

然后在主机文件中,我有

127.0.0.1   localhost
127.0.0.1   www.theb.localhost

我现在面对这些配置的问题是,每当我在浏览器中浏览网站时,

http://www.theb.localhost,然后我将被重定向到http://www.theb.localhost/dashboard(这是 xampp 默认项目文件夹)。我错过了什么吗??

【问题讨论】:

    标签: apache vhosts


    【解决方案1】:
    1. 重新启动 Apache。希望这会奏效。
    2. 如果您已经下载了 Xampp 的 VM 版本(已安装的那个),那么这将无法正常工作,因为它无法访问您的本地文件,请在此处获取非 VM 版本https://sourceforge.net/projects/xampp/files/XAMPP%20Mac%20OS%20X/7.4.6/xampp-osx-7.4.6-0-installer.dmg/download

    【讨论】:

    • 不知何故,在尝试了@Tristanisginger 建议的 xampp 7.4.6 版本后,它仍然以某种方式失败。之后,我重新安装了 xampp 7.2 的非 VM 的原始版本,虚拟主机被放回了与我发布的配置相同的位置,然后它就可以工作了。不太确定这里解决了什么,但我打算将其标记为已解决。