首先配置端口
访达窗口下按command + shift + G,出现前往文件夹选项,输入路径/private/etc/apache2/extra。进入文件夹后打开文件httpd-vhosts.conf,设置端口。如:
Listen 8000
<VirtualHost *:8000>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "/Library/WebServer/Documents"
ServerName zhihuitou.com
ErrorLog "/private/var/log/apache2/webServer_log"
CustomLog "/private/var/log/apache2/webServer_log" common
</VirtualHost>
详情端口设置参照Mac 下apache2.4配置多端口。
然后相同方法回到路径/private/etc,打开hosts文件。在下边键入要设置的虚拟域名。如:
127.0.0.1 www.zhitoufang.com