如何在OSX中更改xampp htdocs目录?

时间:2011-11-09 05:00:29

标签: macos apache xampp

我想更改XAMPP的htdocs目录。我按照说明从这个问题创建了一个虚拟主机:

Make XAMPP/Apache serve file outside of htdocs

这在Windows 7上工作正常,但是当我在OSX上尝试时,转到mysite.local只会加载xampp启动画面(mysite.local / xampp / index.html)。我重新启动了Web服务器。我在httpd-vhosts.conf中声明的虚拟主机是:

<VirtualHost *:80>

DocumentRoot Users/username/Documents/sitename.com

ServerName sitename.localhost

<Directory Users/username/Documents/sitename.com>

Order allow,deny 
Allow from all

</Directory>
编辑:我有这个工作。根据{{​​3}},在OSX中,必须对httpd.conf进行两处更改,首先是取消注释

#Include /Applications/xampp/etc/extra/httpd-vhosts.conf

第二,将用户从nobody更改为用于登录OSX的用户名。您可能还需要删除浏览器的缓存。

4 个答案:

答案 0 :(得分:20)

在文本编辑器中打开以下文件。

  

/Applications/XAMPP/xamppfiles/etc/httpd.conf

搜索“DocumentRoot”,如果下面的行前面有一个#而不是它的注释删除它并更改引号之间的路径

DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"

现在搜索下面的行并根据需要更改引号之间的路径。

<Directory "/Applications/XAMPP/xamppfiles/htdocs">

注意:类似于~/的路径无法使用绝对路径。

答案 1 :(得分:0)

通过编辑httpd.conf来解决,如编辑

中所述

答案 2 :(得分:0)

如果转发到用户root中的目录,则:

DocumentRoot "/Users/<your username here>/Sites"
<Directory "/Users/<your username here>/Sites">

答案 3 :(得分:0)

除了上面提到的答案之外,我还必须更改XAMPP/xampfiles/etc/httpd.conf中提及用户名的行。默认设置为daemon,我将其更改为我的用户名;所以没有许可问题。

相关问题