經(jīng)研究弟蚀,只需要修改三個(gè)文件
1.編輯/etc/apache2/httpd.conf文件
a.
去掉 177行
'#LoadModule php7_module libexec/apache2/libphp7.so'
前面的#號(hào)
b.
去掉 517行
'#Include /private/etc/apache2/extra/httpd-vhosts.conf'
前面的#號(hào)
2.編輯/etc/apache2/extra/httpd-vhosts.conf文件
添加以下配置
'#配置localhost 防止配置了其他域名localhost無法使用'
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "/Library/WebServer/Documents"
ServerName localhost
ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log"
CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common
<Directory /Library/WebServer/Documents>
Require all granted
</Directory>
</VirtualHost>
'#配置ceshi.cn'
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "/Users/xxx/WebServer"
ServerName ceshi.cn
ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log"
CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common
<Directory /Users/xxx/WebServer>
Require all granted
</Directory>
</VirtualHost>
3.編輯/etc/hosts文件
添加一行
127.0.0.1 ceshi.cn
注意:修改以上配置要 sudo apachectl restart重啟
如果發(fā)現(xiàn)瀏覽器輸入ceshi.cn出現(xiàn) 403 Forbidden灌砖,很有可能/Users/xxx/WebServer文件夾下沒有index.html