1、mac本身自带apache服务器,只需要修改3个文件的配置即可
2、打开finder前往文件夹 输入/etc 找到apache2文件夹下的httpd.conf
修改文件中的代码为
#AllowOverride none
#Require all denied
#2017-05-26
Require all granted
AllowOverride all
AllowOverride all
Allow from all
Include /private/etc/apache2/extra/httpd-vhosts.conf
注:找到这行代码 把注释取消掉
3、在apache2 中extra文件夹下打开httpd-vhosts.conf
修改文件中的代码为
#ServerAdmin webmaster@mysite.local
DocumentRoot "/Users/xiekai/xn/"
ServerName w.xn.com
ServerAlias www.dummy-host.example.com
ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log"
CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common
#DocumentRoot "/Users/teenker/xiekai/dev/"
#ServerName w.www.xiekai.com
<Directory /Users/xiekai/xn/>
Options All
Allow from All
AllowOverride All
</Directory>
4、在etc文件夹下打开hosts文件
修改如下
127.0.0.1 w.xn.com //自己配的地址
255.255.255.255 broadcasthost
::1 localhost
0.0.0.0 account.jetbrains.com
5、sudo apachectl restart
重启服务即可 或者重启电脑