安装完xampp后,想添加一个virsualhost,一直报错。呕心沥血之路呀xampp 在国内就是个坑,网上错误的帖子一大堆
第一步,配置本地hosts
sudo vi /etc/hosts
在后面添加你的域名xxx.com
127.0.0.1 xxx.com
第二步 启用apache的虚拟主机功能
打开配置文件 vi /Applications/XAMPP/xamppfiles/etc/httpd.conf
找到下面这一行,去掉最前面的#
Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf
第三步 配置虚拟主机
首先打开配置文件 vi /Applications/XAMPP/etc/extra/httpd-vhosts.conf
清空里面的内容,因为是新安装的,不清空也可以
先把localhost的virsualhost配置一下,不然会出错,一般都是卡在这里了。我的网站编辑器有问题,查看页面源码可以看到配置文件。
默认虚拟主机
<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>
<Virtualhost *:80>
ServerName www.aaa.com
DocumentRoot "/Users/lichengyan/Documents/php/test"
<Directory "/Users/lichengyan/Documents/php/test">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
</Virtualhost>
第四步 如果经过以上步骤重启apache还是有403错误, 就找到/Applications/XAMPP/xamppfiles/etc/httpd.conf
重点 日他大** 就这么一句话每次在mac上配置都给卡到这 卡的一肚子火气
修改里面的User和Group, User修改为你的电脑的用户名, group修改为staff
也就是
User daemon
User mac
Group daemon
Group staff