[英]how to change xampp htdocs directory in OSX?
I want to change XAMPP's htdocs directory.我想更改 XAMPP 的 htdocs 目录。 I followed the instructions to create a virtual host from this question:
我按照说明从这个问题创建了一个虚拟主机:
Make XAMPP/Apache serve file outside of htdocs 在 htdocs 之外制作 XAMPP/Apache 服务文件
this works fine on Windows 7, however when I try it on OSX, going to mysite.local just loads the xampp splash screen (mysite.local/xampp/index.html).这在 Windows 7 上运行良好,但是当我在 OSX 上尝试时,转到 mysite.local 只会加载 xampp 初始屏幕(mysite.local/xampp/index.html)。 I have restarted the web server.
我已经重新启动了网络服务器。 My virtual host declared in httpd-vhosts.conf is:
我在 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>
Open the following file in a text editor. 在文本编辑器中打开以下文件。
/Applications/XAMPP/xamppfiles/etc/httpd.conf
/Applications/XAMPP/xamppfiles/etc/httpd.conf
Search for "DocumentRoot", if the line below has a #
in front of it than it's commented remove it and change the path between the quote 搜索“DocumentRoot”,如果下面的行在其前面有一个
#
而不是它的注释删除它并更改引用之间的路径
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"
Now search for the line below and change the path between the quotes to your needs. 现在搜索下面的行并根据需要更改引号之间的路径。
<Directory "/Applications/XAMPP/xamppfiles/htdocs">
~/
won't work use the absolute path. ~/
类似的路径使用绝对路径。 If you forward to a directory in your user root, then: 如果转发到用户root中的目录,则:
DocumentRoot "/Users/<your username here>/Sites"
<Directory "/Users/<your username here>/Sites">
Other than the answers mentioned above, I also had to change the line in XAMPP/xampfiles/etc/httpd.conf
where it mentions username. 除了上面提到的答案,我还必须更改
XAMPP/xampfiles/etc/httpd.conf
中提到用户名的行。 the default was set to daemon
and I changed it to my username; 默认设置为
daemon
,我将其更改为我的用户名; so there was no permission problem. 所以没有许可问题。
I would like to expand this answer for 2022.我想将这个答案扩展到 2022 年。
You will have to change 3 files if you want to keep web root in another directory.如果要将 Web 根目录保存在另一个目录中,则必须更改 3 个文件。 Let's say that you have installed XAMPP regularly, but your httpd directory is on another volume.
假设您已定期安装 XAMPP,但您的 httpd 目录位于另一个卷上。 Let's say in
work/xampp/
假设在
work/xampp/
Open /Applications/XAMPP/xamppfiles/apache2/conf/httpd.conf
and change it to the following打开
/Applications/XAMPP/xamppfiles/apache2/conf/httpd.conf
并将其更改为以下
Alias /bitnami/ "/Applications/XAMPP/xamppfiles/apache2/htdocs/"
Alias /bitnami "/Applications/XAMPP/xamppfiles/apache2/htdocs"
DocumentRoot "/Applications/XAMPP/xamppfiles/apache2/htdocs"
<Directory "/Applications/XAMPP/xamppfiles/apache2/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
DocumentRoot "/Volumes/work/xampp"
<Directory "/Volumes/work/xampp">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
We have added我们添加了
DocumentRoot "/Applications/XAMPP/xamppfiles/apache2/htdocs"
and the block和块
DocumentRoot "/Volumes/work/xampp"
<Directory "/Volumes/work/xampp">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Open file /Applications/XAMPP/xamppfiles/etc/extra/httpd-vhosts.conf
and change it to the following打开文件
/Applications/XAMPP/xamppfiles/etc/extra/httpd-vhosts.conf
并将其更改为以下内容
<VirtualHost *:80>
DocumentRoot "/Volumes/work/xampp"
</VirtualHost>
<VirtualHost yoursite.mac:80>
ServerName yoursite.mac
ServerAlias www.yoursite.mac
ServerAdmin webmaster@yoursite.mac
DocumentRoot "/Volumes/work/xampp/yoursite.mac/webroot"
ErrorLog "/Volumes/work/xampp/yoursite.mac/logs/oll.mac-error_log"
CustomLog "/Volumes/work/xampp/yoursite.mac/logs/oll.mac-access_log" common
<Directory "/Volumes/work/xampp">
Require all granted
</Directory>
</VirtualHost>
Open /etc/hosts
as a sudo and add your new site to it以 sudo 的身份打开
/etc/hosts
并将您的新站点添加到其中
127.0.0.1 yoursite.mac
solved by editing httpd.conf 通过编辑httpd.conf解决
I have got this working. 我有这个工作。 As per http://www.acwolf.com/blog/2009/February/xampp-virtual-hosts-mac , in OSX it is necessary to make two changes to httpd.conf, first, uncomment
根据http://www.acwolf.com/blog/2009/February/xampp-virtual-hosts-mac ,在OSX中,有必要对httpd.conf进行两处更改,首先,取消注释
#Include /Applications/xampp/etc/extra/httpd-vhosts.conf
and second, change the user from nobody to the username you use to log into OSX. 第二,将用户从nobody更改为用于登录OSX的用户名。 You may also need to delete your browser's cache.
您可能还需要删除浏览器的缓存。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.