一:在終端輸入 ?vim ? /Applications/MAMP/conf/apache/httpd.conf ?
搜索httpd-vhosts.conf 找到:#Include ?/Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
將#去掉,使虛擬地址的配置文件生效。
二:vim ? /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf,
在配置文件最后加入需要配置的虛擬主機配置
#配置test.com
? ? ServerAdmin test.com
? ? DocumentRoot "/Applications/MAMP/htdocs/test"
? ? ServerName test.com
? ? ServerAlias test.com
? ? ErrorLog "logs/test.com-error_log"
? ? CustomLog "logs/test.com-access_log" common
#配置active.com
? ? ServerAdmin active.com
? ? DocumentRoot "/Applications/MAMP/htdocs/active/"
? ? ServerName active.com
? ? ServerAlias active.com
? ? ErrorLog "logs/active.com-error_log"
? ? CustomLog "logs/active.com-access_log" common
三:進入hosts 文件 vim /etc/hosts
加入
127.0.0.1 ?test.com
127.0.0.1 ? active.com
重啟appache服務器,打開瀏覽器輸入test.com 和activie.com即可訪問對應網站