Mac下XAMPP本地多站点配置

涉及的配置文件:hosts,httpd.conf,httpd-vhosts.conf

1. hosts文件添加自定义域名,sudo nano /etc/hosts


Mac下XAMPP本地多站点配置_第1张图片

修改完后,control+x保存退出

2. httpd-conf配置,打开配置文件所在目录 open /Applications/XAMPP/xamppfiles/etc

Mac下XAMPP本地多站点配置_第2张图片

使用编辑器打开httpd.conf,找到httpd-vhosts.conf,删除前面的“#”号,在末尾添加

#Options Indexes FollowSymLinks ExecCGI Includes #don't permission see list

Options All 

AllowOverride All

Order allow,deny

Allow from all

Mac下XAMPP本地多站点配置_第3张图片

Options:控制哪些服务器特性 

    All:用户可以在此目录做任何操作

    None:不允许访问此目录

    Indexes:是否显示文件列表

Allow:允许哪个版本可以访问

Deny:禁止哪些主机访问

Order:控制Deny和Allow生效顺序

AllowOverride:根据All和None的值来决定是否读取.htaccess文件中的信息来改变原配置

.htaccess控制相关目录下的配置

3. httpd-vhosts.conf配置,open /Applications/XAMPP/xamppfiles/etc/extra

Mac下XAMPP本地多站点配置_第4张图片

编辑器打开httpd-vhosts.conf,在末尾添加

Mac下XAMPP本地多站点配置_第5张图片

完成后重启apache即可。

4. 如果出现错误:xampp:Access forbidden!You don't have permission to access the requested directory,修改httpd-vhosts.conf文件

        Options All

        AllowOverride All 

        Order deny,allow 

        Allow from all 

    Require all granted 

Mac下XAMPP本地多站点配置_第6张图片

参考:

https://www.cnblogs.com/heiniuhaha/archive/2011/10/14/2212478.html

http://blog.csdn.net/wj610671226/article/details/64513919

你可能感兴趣的:(Mac下XAMPP本地多站点配置)