比如要添加1个local域名:
linyufang.local

  1. 首先要编辑/etc/hosts文件
sudo vim /etc/hosts

添加这个一行

127.0.0.1 linyufang.local
  1. 配置httpd.conf
sudo vim /etc/apache2/httpd.conf

输入以下内容

NameVirtualHost *:80
<VirtualHost *:80>
  #ServerAdmin dns@red.com
  ServerName linyufang.local
  DocumentRoot /Users/weston/projects/beautyonly.net
  Options +Indexes
  ErrorLog /tmp/error.log
  CustomLog /tmp/access.log combined
  <Directory /Users/weston/projects/linyufang.net>
    Options Indexes FollowSymLinks MultiViews Includes
    AllowOverride All
    Order allow,deny
    allow from all
  </Directory>
</VirtualHost>
  1. 重启apache
    sudo apachectl restart

转载请注明:韦旭红的点点滴滴 » Mac Apache VirtualHost Configuration….