目标

目标

目标

我正在尝试在单个 Apache 服务器 - MAMP 中托管多个域“虚拟主机”。


试图

在我的 MAMP 中,我选择端口8888


host file我的 Mac 电脑的末尾有这个

/etc/hosts

127.0.0.1   l.ssc.com
127.0.0.1   l.pm.com

httpd配置文件

我已经添加

<VirtualHost l.ssc.com:8888 >
    ServerName l.ssc.com
    DocumentRoot "/Applications/MAMP/htdocs/code/benu/ssc-portal/public/"
    <Directory "/Applications/MAMP/htdocs/code/benu/ssc-portal/public/">
        # Require all granted
        Options All
        AllowOverride All
        Order allow,deny
        Allow from all
        XSendFilePath "/Applications/MAMP/htdocs"
    </Directory>
</VirtualHost>


<VirtualHost l.pm.com:8888 >
    ServerName l.pm.com
    DocumentRoot "/Applications/MAMP/htdocs/code/biossantibodies/public/"
    <Directory "/Applications/MAMP/htdocs/code/biossantibodies/public/">
        # Require all granted
        Options All
        AllowOverride All
        Order allow,deny
        Allow from all
        XSendFilePath "/Applications/MAMP/htdocs"
    </Directory>
</VirtualHost>

并重新启动我的 MAMP。


结果

参观完这两个地方后,

http://l.ssc.com:8888/

http://l.pm.com:8888/

我一直看到同一个网站被加载,这是我的第一个被声明的网站httpd配置文件文件。

在此处输入图片描述


我希望看到我的http://l.pm.com:8888/加载不同的文档根目录。


问题

如何着手并调试这个问题?


我现在愿意接受任何建议。

如能得到任何提示/建议/帮助都将非常感激!

答案1

这是我为实现这一目标所采取的步骤

- 注释掉股票 MAMP DOCUMENT_ROOT

/应用程序/MAMP/conf/apache/httpd.conf

# MAMP DOCUMENT_ROOT !! Don't remove this line !!

# DocumentRoot "/Applications/MAMP/htdocs/code/benu/ssc-portal/public"
# <Directory "/Applications/MAMP/htdocs/code/benu/ssc-portal/public">
#     Options All
#     AllowOverride All
#     Order allow,deny
#     Allow from all
#     XSendFilePath "/Applications/MAMP/htdocs"
# </Directory>

确保包含一个 vhost 文件,方法是取消注释下面的行,如下所示

# Virtual hosts
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf

- 将配置添加到 vhost 文件

/应用程序/MAMP/conf/apache/extra/httpd-vhosts.conf

NameVirtualHost *:8888

<VirtualHost *:8888 >
    ServerName l.ssc.com
    DocumentRoot "/Applications/MAMP/htdocs/code/benu/ssc-portal/public/"
    <Directory "/Applications/MAMP/htdocs/code/benu/ssc-portal/public/">
        # Require all granted
        Options All
        AllowOverride All
        Order allow,deny
        Allow from all
        XSendFilePath "/Applications/MAMP/htdocs"
    </Directory>
</VirtualHost>


<VirtualHost *:8888 >
    ServerName l.pm.com
    DocumentRoot "/Applications/MAMP/htdocs/code/biossantibodies/public/"
    <Directory "/Applications/MAMP/htdocs/code/biossantibodies/public/">
        # Require all granted
        Options All
        AllowOverride All
        Order allow,deny
        Allow from all
        XSendFilePath "/Applications/MAMP/htdocs"
    </Directory>
</VirtualHost>

- 重新启动MAMP

相关内容