XAMPP(Apache+MySQL+PHP+PERL)是一个功能强大的建 XAMPP 软件站集成软件包。这个软件包原来的名字是LAMPP,但是为了避免误解,最新的几个版本就改名为 XAMPP 了。它可以在Windows、Linux、Solaris、M ac OS X 等多种操作系统下安装使用,支持多语言:英文、简体中文、繁体中文、韩文、俄文、日文等。
本文为大家讲解的是如何在Mac系统下配置xampp集成环境的虚拟主机(vhost),感兴趣的同学参考下。
先在hosts文件里加入virtual host的域名,指向127.0.0.1 我一般使用的命名规则是dev-domainname.com
sudo nano /private/etc/hosts
# VirtualHosts Mapping
127.0.0.1 dev-domainname.com
接下来配置Apache,打开Apache的配置文件 /Applications/XAMPP/etc/httpd.conf
搜索 “Virtual hosts”
# Virtual hosts
# Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf
把第二行注释打开,让Apache去读虚拟主机的配置文件
# Virtual hosts
Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf
在以上httpd-vhosts.conf里添加Virtual Host的配置
# localhost
<VirtualHost *:80>
ServerName localhost
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"
<Directory "/Applications/XAMPP/xamppfiles/htdocs">
Options Indexes FollowSymLinks Includes execCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
# My custom host
<VirtualHost *:80>
ServerName mysite.local
DocumentRoot "/Users/yourusername/path/to/your/site"
<Directory "/Users/yourusername/path/to/your/site">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
ErrorLog "logs/mysite.local-error_log"
</VirtualHost>
重启Apache,访问dev-domainname.com出现403错误,在httpd.conf里面搜索User Deamon,把deamon改成OS的用户名,重启Apache,就可以了。
You don\'t have permission to access the requested directory. There is either no index document or the directory is read-protected.
If you think this is a server error, please contact the webmaster.
Error 403
a1.com
Apache/2.4.10 (Unix) OpenSSL/1.0.1j PHP/5.6.3 mod_perl/2.0.8-dev Perl/v5.16.3