MAC上的XAMPP - 将目录和虚拟主机更改为其他卷

时间:2016-10-01 09:04:16

标签: macos apache xampp

我正在尝试从

移动默认的htdocs文件夹
  

/应用/ xamppfiles / htdocs中/

的另一个分区上的文件夹
  

/卷/网络服务器/ XAMPP / htdocs中/

恰好是安装XAMPP for Windows的目录,允许我为我的网站项目使用相同的目录,无论我是在Windows还是MAC上编码。 (注意:我使用的是带有Bootcamp和ParagonNTFS的Macbook Air,因此可以读/写NTFS分区)

我已经成功调整了httd.conf和vhost.conf文件,并设法重新定位localhost目录以指向其他卷上的文件,但我不想更改localhost目录,而是创建一个新虚拟将我指向其他卷的主持人。简而言之,我想要这三个域

  

localhost - > /应用/ xamppfiles / htdocs中/

     

site1.local - > /卷/网络服务器/ XAMPP / htdocs中/ PROJECT1 /

     

site2.local - > /卷/网络服务器/ XAMPP / htdocs中/项目2 /

现在的问题是,当我在浏览器中输入site1.local或site2.local时,浏览器会将我重定向到谷歌,因为它无法找到文件夹。

如果我更改了localhost的转发目录,那么一切正常。

  

localhost - > /卷/网络服务器/ campp / htdocs中/ PROJECT1 /

在这里播放配置:

httd.conf

DocumentRoot "/Volumes/Webserver/xampp/htdocs"
<Directory "/Volumes/Webserver/xampp/htdocs">

Include etc/extra/httpd-vhosts.conf

的httpd-vhosts.conf

# Project1
<VirtualHost *:80>
    ServerName site1.local
    DocumentRoot "/Volumes/Webserver/xampp/htdocs/project1"
    <Directory "/Volumes/Webserver/xampp/htdocs/project1">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Require all granted
    </Directory>
    ErrorLog "logs/site1.local-error_log"
</VirtualHost>


# Project2
<VirtualHost *:80>
    ServerName site2.local
    DocumentRoot "/Volumes/Webserver/xampp/htdocs/project2"
    <Directory "/Volumes/Webserver/xampp/htdocs/project2">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Require all granted
    </Directory>
    ErrorLog "logs/site2.local-error_log"
</VirtualHost>

# localhost [must be included as the default named server]
<VirtualHost *:80>
    ServerName localhost
    DocumentRoot "/Volumes/Webserver/xampp/htdocs"
    <Directory "/Volumes/Webserver/xampp/htdocs">
        Require all granted
    </Directory>
</VirtualHost>

我可以很好地访问localhost,但是site1和site2不能正常工作。如果我更改localhost的文档,我可以访问正常。

主机

127.0.0.3 site2.local
127.0.0.2 site1.local
127.0.0.1 localhost

我尝试为每个站点分配自己的IP地址,但没有成功。

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:1)

不得不重启大约10次,但现在看来设置已经生效了。我可以确认上述安排有效但需要完全重启才能生效。