After installing XAMPP, want to add a virsualhost, always error. Check for a half-day information, are nonsense, and later saw a foreign article, finally out, tidy up a bit.
The first step is to configure the local hosts
sudo vi/etc/hosts
Add your domain name at the back xxx.com
127.0.0.1 xxx.com
The second step is to enable the Apache Virtual Host feature
Open configuration file vi/applications/xampp/xamppfiles/etc/httpd.conf
Find the following line, remove the front #
#Include/applications/xampp/etc/extra/httpd-vhosts.conf
The third step is to configure the virtual host
First open the configuration file vi/applications/xampp/etc/extra/httpd-vhosts.conf
Empty the contents of the content, because it is newly installed, do not empty or can
First the virsualhost of the localhost configuration, or it will be wrong, is usually stuck here. My website editor has the problem, view the page source code can see the configuration file.
Default Virtual Host
<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>
Then add your own virtual 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>
Fourth step if you restart Apache after the above steps, there are 403 errors and you will find/applications/xampp/xamppfiles/etc/httpd.conf
Modify the user and group inside, users change to your computer's username, group changed to staff
That is
#User Daemon
User mac
#Group Daemon
Group Staff
Reprint: Mac system XAMPP configuration virtual Host