首先進入apache的配置文件httpd.conf,若是是mamp,路徑
是/Applications/MAMP/conf/apache/httpd.conf,用文本編輯器打開,command+f查找一下‘vhosts’關鍵字,來到了這一行html
#Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
把前面的#號去掉,表示這句話生效,這句話的意思就是使虛擬地址的配置文件生效。
保存後,用文本編輯器打開 /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf,加入須要配置的虛擬地址,大概是這樣的:
apache
<VirtualHost *:80> DocumentRoot "/Users/Cancel/Develop/MAMP/test" ServerName lypton.test.com ServerAlias lypton.test.com <Directory "/Users/Cancel/Develop/MAMP/test"> Options Indexes FollowSymLinks AllowOverride All Order deny,allow Allow from all </Directory> </VirtualHost>