修改hosts文件
cd /private/etc
vim hosts
显示
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
127.0.0.1 www.test.com
127.0.0.1 tpshop.test.com
进入apache
cd /etc/apache2/
修改httpd.conf,没有权限
sudo chmod 777 httpd.conf
把包含vhost那两行前的#号去掉,让extra下的扩展文件生效
给予权限
找到
Require all denied修改为
Require all granted
有两处需要修改
配置域名
进入extra文件夹,编辑httpd-vhosts.conf
cd extra
vi httpd-vhosts.conf
在最后处添加自己的域名
<VirtualHost *:80>
DocumentRoot "/Users/wxx/PhpstormProjects/test"
ServerName www.test.com
ErrorLog "/private/var/log/apache2/www.test.com-error_log"
CustomLog "/private/var/log/apache2/www.test.com-access_log" common
</VirtualHost>
本地浏览可见