1 在配置文件中开启虚拟配置
# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf ,去除前面的#
2 打开Include /private/etc/apache2/extra/httpd-vhosts.conf
① 注释或删除默认配置
② 以下是我新增
DocumentRoot "/Users/jackwoo/wwwroot/meal"
ServerName www.meal.com
ErrorLog "/private/var/log/apache2/meal-error_log"
CustomLog "/private/var/log/apache2/meal-access_log" common
Require all granted
注意:apache 2.4以上版本中需要在目录下面添加 Require all granted,否则无论怎么访问都是403。